如何使用 Eclipse 和 IvyDE 以及 shell 脚本来驯服一个项目,使开发、构建和发布变得易于管理?
How to tame a project using Eclipse and IvyDE together with shell scripts to make development, build, and publishing manageable?
我一直在研究一个 Web 应用程序项目,该项目在开发过程中结合使用 Ivy 和一组 shell 脚本来手动启动应用程序java 可在 运行 时间通过指定硬编码 class 路径执行。我主要来自 .NET/NuGet 背景并且有一些其他包管理器的经验,例如 NPM、Ruby Gems、Rust cargo,我想知道相同的命令行工具在哪里 Java.我一直在使用 java -jar ivy.jar
但这似乎只是 resolve/install 全局依赖项,那么构建、运行 并最终发布应用程序呢?
除了工具,我还想知道手动调整 classpath 是否是 Java 中的常规业务,或者是否有像其他依赖项管理器一样以更面向图形的方式设置依赖项的最佳实践.我觉得我在这里缺少一些明显的解决方案,但我对该主题的搜索并没有让我放心。最终,我想要一个用 code/configuration 制定的合理解决方案,以便任何开发人员都可以选择它,并且如果需要,它可以 运行 完全脱离 eclipse。
您在搜索中查看过 Maven 吗?
它填补了包管理方面以及其他一些方面,如构建、测试。
https://maven.apache.org/
在构建时,有像Maven and Gradle. These allow your dependencies, and the tool builds the dependency graph to determine the required transitive dependencies. Both Maven and Gradle represent the dependencies in directed acyclic-graph, but Maven's DAG is far more constrained than Gradle's. Maven is very declarative, specified in XML, and is very much our way or the highway. Gradle is very flexible, with build scripts specified as Groovy programs. Here's a feature-by-feature比较这样的工具(偏向Gradle)。
就Maven而言,你所要做的就是:
mvn clean install
如果你想可视化依赖图:
mvn dependency:tree
在运行的时候,就是另外一回事了。
通常,Java 应用程序被捆绑到 WAR 或 EAR 文件中。这些是经过美化的 ZIP 文件,其中包含应用程序及其所有依赖项。 WAR 文件解压后如下所示:
+-+ WEB-INF
| |
| +-- classes
| | \_ application specific classes
| +-- lib
| | \_ bundled JAR files for required dependencies
| +-- web.xml
| \_ main web application configuration
+-- ... web assets
WAR 和 EAR 文件部署到应用程序服务器(Tomcat、JBoss 等),该服务器管理应用程序之间的共享依赖关系。
在应用程序服务器之外,这有点棘手。最简单的方法是将应用程序安装为可执行 JAR 文件,同时安装它的所有依赖项。 JAR 文件可以有 "MAINFEST.MF" file included with it that lists all of the dependent JARs. A build tool like Maven will automatically configure the JAR to reference its dependencies and package the application and its dependencies in a ZIP file (see the Maven assembly plugin).
另一种方法是所谓的 "fat-JAR" 或 "uber-JAR",它是一个包含其他 JAR 的 JAR,或者主 JAR 仅包含依赖项 JAR 的分解内容(请参阅 Maven shade plugin ).
最后是 OSGi,它在 运行 时管理依赖项。 OSGi 是一种开放标准,由 Apache Felix 或 Eclipse Equinox 等容器实现。下面介绍如何设置 Eclipse Equinox 应用程序。您将应用程序作为 "plugin" 开发到这些框架之一中。但是,作为一个很好的好处,您可以管理多个版本的依赖项,甚至可以自动更新。
我一直在研究一个 Web 应用程序项目,该项目在开发过程中结合使用 Ivy 和一组 shell 脚本来手动启动应用程序java 可在 运行 时间通过指定硬编码 class 路径执行。我主要来自 .NET/NuGet 背景并且有一些其他包管理器的经验,例如 NPM、Ruby Gems、Rust cargo,我想知道相同的命令行工具在哪里 Java.我一直在使用 java -jar ivy.jar
但这似乎只是 resolve/install 全局依赖项,那么构建、运行 并最终发布应用程序呢?
除了工具,我还想知道手动调整 classpath 是否是 Java 中的常规业务,或者是否有像其他依赖项管理器一样以更面向图形的方式设置依赖项的最佳实践.我觉得我在这里缺少一些明显的解决方案,但我对该主题的搜索并没有让我放心。最终,我想要一个用 code/configuration 制定的合理解决方案,以便任何开发人员都可以选择它,并且如果需要,它可以 运行 完全脱离 eclipse。
您在搜索中查看过 Maven 吗?
它填补了包管理方面以及其他一些方面,如构建、测试。 https://maven.apache.org/
在构建时,有像Maven and Gradle. These allow your dependencies, and the tool builds the dependency graph to determine the required transitive dependencies. Both Maven and Gradle represent the dependencies in directed acyclic-graph, but Maven's DAG is far more constrained than Gradle's. Maven is very declarative, specified in XML, and is very much our way or the highway. Gradle is very flexible, with build scripts specified as Groovy programs. Here's a feature-by-feature比较这样的工具(偏向Gradle)。
就Maven而言,你所要做的就是:
mvn clean install
如果你想可视化依赖图:
mvn dependency:tree
在运行的时候,就是另外一回事了。
通常,Java 应用程序被捆绑到 WAR 或 EAR 文件中。这些是经过美化的 ZIP 文件,其中包含应用程序及其所有依赖项。 WAR 文件解压后如下所示:
+-+ WEB-INF
| |
| +-- classes
| | \_ application specific classes
| +-- lib
| | \_ bundled JAR files for required dependencies
| +-- web.xml
| \_ main web application configuration
+-- ... web assets
WAR 和 EAR 文件部署到应用程序服务器(Tomcat、JBoss 等),该服务器管理应用程序之间的共享依赖关系。
在应用程序服务器之外,这有点棘手。最简单的方法是将应用程序安装为可执行 JAR 文件,同时安装它的所有依赖项。 JAR 文件可以有 "MAINFEST.MF" file included with it that lists all of the dependent JARs. A build tool like Maven will automatically configure the JAR to reference its dependencies and package the application and its dependencies in a ZIP file (see the Maven assembly plugin).
另一种方法是所谓的 "fat-JAR" 或 "uber-JAR",它是一个包含其他 JAR 的 JAR,或者主 JAR 仅包含依赖项 JAR 的分解内容(请参阅 Maven shade plugin ).
最后是 OSGi,它在 运行 时管理依赖项。 OSGi 是一种开放标准,由 Apache Felix 或 Eclipse Equinox 等容器实现。下面介绍如何设置 Eclipse Equinox 应用程序。您将应用程序作为 "plugin" 开发到这些框架之一中。但是,作为一个很好的好处,您可以管理多个版本的依赖项,甚至可以自动更新。