这是我的pom文件的片段.
....
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
......
</configuration>
</execution>
</executions>
</plugin>
</plugins>
...
Run Code Online (Sandbox Code Playgroud)
我在命令中成功使用它
mvn install
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试将其封装到"pluginManagement"标签中时,maven-dependency-plugin当我启动install目标时停止工作.为什么"pluginManagement"标签会改变构建行为?或者我应该使用其他目标或选项?
我正在开发一个依赖X的项目.反过来,X依赖于Y.
我曾经明确地将Y包含在我项目的pom中.然而,它没有被使用并且使事情变得更清洁,而是将它作为依赖项添加到X的pom中.X被标记为发布依赖项.
问题是,从我的项目的pom中删除Y并将其添加到X的pom后,我的项目没有接受它mvn -U clean package.我知道-U更新快照但不更新版本.
因此,在不删除〜/ .m2/repository目录的情况下,如何强制重新下载X的pom?此外,我尝试运行dependency:purge-local-repository,它也没有工作.
我在一个新的Workspace中创建了一个新的简单Maven项目.
当我打开pom.xml的Dependencies在Eclipse编辑器视图,我选择Add..的依赖,也没有搜索结果无论是什么的搜索条件搜索字段I输入:
例如,它会立即给我Results for 'spring' (0).
在我的其他工作区中,使用我现有的项目,我没有这个问题.
有办法解决这个问题吗?
我正在编写一个验收测试项目,由于各种原因,这依赖于另一个打包为WAR的项目.我已经设法使用maven-dependency-plugin解压缩WAR,但我无法让我的项目包含unpacked WEB-INF/lib/*.jar并WEB-INF/classes/*包含在类路径中,因此构建失败.有没有办法将这些文件包含在类路径中,还是有更好的依赖WAR的方法?
非常感谢.
我正在尝试让Project B下拉(并解压缩)由Project A构建并部署到远程存储库的ZIP .
使用maven-assembly-plugin包装类型创建并附加ZIP pom:
<artifactId>project-a</artifactId>
<name>ZIP</name>
<description>Used by Project B</description>
<packaging>pom</packaging>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>distribution-package</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/scripts.xml</descriptor>
</descriptors>
<tarLongFileMode>gnu</tarLongFileMode>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
试图从项目B的pom中拉下来maven-dependency-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-scripts</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/staging</outputDirectory>
<stripVersion>true</stripVersion>
<artifactItems>
<artifactItem>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<overWrite>true</overWrite>
<type>zip</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
失败了: [ERROR] Failed to execute goal on project ...: …
zip pom.xml maven maven-assembly-plugin maven-dependency-plugin
在我的插件中,我需要处理依赖关系层次结构并获取有关每个依赖关系的信息(groupId,artifactId,version等)以及它是否被排除.做这个的最好方式是什么?
我有Maven项目,包含repo和stuff中的依赖项.我想用所有依赖项"导出"它的源代码,以便我可以在IDE中成功打开它,而不需要在机器上运行Maven.
将项目打包到war文件中时,它包含所有依赖项.
所以我希望将所有依赖项和我的源集合在一个地方,可以使用IDE(Eclipse或IDEA)打开所有检测到的库吗?
我需要基本上完成以下任务:
provided.我似乎无法完成第二部分.有没有更好的方法来做到这一点,而不是我在下面这样做?我实际上是将这些JAR部署到服务器上的lib目录中.不幸的是,下面的代码包括所有JAR,甚至包括JAR provided,但不包括项目输出JAR.我应该使用不同的插件吗?
<?xml version="1.0"?>
<project>
...
<dependencies>
<dependency>
<groupId>com.provided</groupId>
<artifactId>provided-lib</artifactId>
<version>1.2.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>/hello</outputDirectory>
<excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud) 将Maven依赖项声明为仅用于测试运行时(但不是测试编译)类路径的最佳方法是什么?
具体来说,我希望slf4j-api(一个日志外观)作为典型的编译范围依赖,但我想slf4j-simple(仅适用于单元测试的准分子实现)仅在测试运行时类路径上(测试编译不需要它).我一直这样做:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但是,这方面的缺点是dependency:analyze报告slf4j-simple未使用,大概是因为它不需要编译:
[WARNING] Unused declared dependencies found:
[WARNING] org.slf4j:slf4j-simple:jar:1.7.7:test
Run Code Online (Sandbox Code Playgroud)
我不能使用runtime依赖项,因为我不希望依赖项传递继承(例如,所以下游依赖项可以使用log4j等).我尝试runtime过optional=true,但这会产生同样的警告.
(请注意,我也可以设置ignoreNonCompile依赖插件,但这似乎是一个非常生硬的工具,可以隐藏其他潜在的问题.)
如果我们考虑以下示例,"+ - "和"\ - "符号之间的区别是什么,它们表示什么?
[INFO] [dependency:tree]
[INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT
[INFO] +- org.apache.maven.reporting:maven-reporting-impl:jar:2.0.4:compile
[INFO] | \- commons-validator:commons-validator:jar:1.2.0:compile
[INFO] | \- commons-digester:commons-digester:jar:1.6:compile
[INFO] | \- (commons-collections:commons-collections:jar:2.1:compile - omitted for conflict with 2.0)
[INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile
[INFO] \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile
[INFO] \- commons-collections:commons-collections:jar:2.0:compile
Run Code Online (Sandbox Code Playgroud) dependency-management maven maven-dependency-plugin maven-dependency