我在maven项目目录中运行以下命令:
mvn dependency:purge-local-repository
Run Code Online (Sandbox Code Playgroud)
预期的行为是什么?
它会删除(并重新下载吗?)我的本地仓库中已存在的特定项目的所有依赖项(即我所在的目录)还是会删除我本地仓库的所有内容?
我确定这是有效的!
我有一个maven依赖插件配置将java服务包装器放入appassembler目标文件夹中的特定文件夹.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.tanukisoftware</groupId>
<artifactId>wrapper</artifactId>
<version>3.2.1</version>
<classifier>${target.arch.classifier}</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/appassembler/jsw/projectnamehere/lib</outputDirectory>
<destFileName>wrapper-${target.arch}.dll</destFileName>
</artifactItem>
</artifactItem>
</artifactItems>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但它被写为wrapper.dll(它是repo中的文件名).target.arch设置为"windows-x86-32".
这是日志文件的一部分:
[DEBUG] (s) groupId = org.tanukisoftware
[DEBUG] (s) artifactId = wrapper
[DEBUG] (s) version = 3.2.1
[DEBUG] (s) classifier = win32
[DEBUG] (s) type = jar
[DEBUG] (s) overWrite = true
[DEBUG] (s) outputDirectory = <projectfolder>\target\appassembler\jsw\SophisToTradeCacheConsumer\lib
[DEBUG] (s) destFileName = wrapper-windows-x86-32.dll
...
[DEBUG] (f) outputAbsoluteArtifactFilename = false
[DEBUG] (s) outputDirectory = <projectfolder>\target\dependency
[DEBUG] (s) overWriteIfNewer = true
[DEBUG] …Run Code Online (Sandbox Code Playgroud) 这是我的多模块项目的结构:
/root
/api dependencies: slf4j
/foo dependencies: slf4j-log4j12, log4j
Run Code Online (Sandbox Code Playgroud)
换句话说,模块api使用slf4j的日志记录.它不知道日志工具的实现是什么.模块foo添加slf4j-log4j12并log4j执行日志记录.很简单.
现在我正在运行maven-dependency-plugin:analyze-only,这就是它对模块的说法foo:
[WARNING] Unused declared dependencies found:
[WARNING] org.slf4j:slf4j-log4j12:jar:1.6.1:compile
[WARNING] log4j:log4j:jar:1.2.16:compile
Run Code Online (Sandbox Code Playgroud)
意味着插件不理解foo真正需要这些依赖项.我该如何解决这个问题?
我有以下配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze-only</goal>
</goals>
<configuration>
<failOnWarning>false</failOnWarning>
</configuration>
</execution>
<!--Copy the dependencies so ant build has the same versions-->
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/lib</outputDirectory>
<overWriteIfNewer>true</overWriteIfNewer>
<stripVersion>true</stripVersion>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<excludeTransitive>false</excludeTransitive>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
上面的配置会转储同一文件夹中的所有内容.我尝试通过添加测试配置来排除测试范围但是给出了错误:
未能执行目标org.apache.maven.plugins:Maven的依赖关系的插件:2.6:项目pcgen复制依赖(复制依赖):不能排除测试范围,这将排除一切.
有没有办法将测试依赖项与其他依赖项分开,以便我可以复制到不同的文件夹?
我有一个使用许多Maven依赖项的大型webapp.它们作为JAR文件包含在内,但我希望有机会直接在Eclipse中将它们中的一些用作打开的项目.然后依赖项目与m2e链接.
从一些JAR /项目中,需要提取资源.
我怎么能用Maven-dependency-plugin做到这一点?如果工件包含在JAR中,请将其解压缩,然后将文件复制到所需目录.如果工件包含在工件中,它就存在于硬盘驱动器上,文件可以直接访问和复制,无需解压缩.
我已将使用的版本maven-dependency-plugin从2.8 更改为2.10.现在,当我跑步时,mvn dependency:tree -Dverbose我看到以下警告:
[WARNING] Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution
Run Code Online (Sandbox Code Playgroud)
我正在使用的Maven版本是
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T18:37:52+01:00)
Run Code Online (Sandbox Code Playgroud)
-Dverbose输出,但现在他们已经添加了警告?有一个具有以下结构的 jar 文件:
/--
|-dir1
|-file1
|-file2
|-file3
|-dir2
|-dir3
Run Code Online (Sandbox Code Playgroud)
我将过滤器设置为仅从 dir1 获取文件
/--
|-dir1
|-file1
|-file2
|-file3
|-dir2
|-dir3
Run Code Online (Sandbox Code Playgroud)
它成功地仅从该目录中获取文件,但在目标目录中复制的文件放置在 dir1 中,如何从复制的文件中删除路径并仅保留名称。所以file1将被复制到target/file1而不是target/dir1/file1
<includes>dir1/*</includes>
Run Code Online (Sandbox Code Playgroud) 我正在尝试按范围过滤输出dependency:tree。文档(https://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html)指定了一个<scope>完全可以执行此操作的选项,但由于长期存在的错误,它目前已被破坏。有什么解决方法吗?
我有一个私有 Maven 存储库。它在项目的pom.xml中定义
<repository>
<id>some.id</id>
<url>https://some.host/artifactory/some.id</url>
</repository>
Run Code Online (Sandbox Code Playgroud)
在我的中~/.m2/settings.xml,我有正确的身份验证块:
<server>
<id>some.id</id>
<username>pawel.veselov@domain.com</username>
<password>{some-fancy-password-hash-goes-here}</password>
</server>
Run Code Online (Sandbox Code Playgroud)
构建项目时,Maven 能够毫无问题地访问存储库,正如它应该的那样。在调试输出中,我可以看到它应用了凭据。
但是当我尝试直接下载工件时,Maven 似乎根本没有考虑设置文件。
mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get \
-DremoteRepositories=some.id::::https://some.host/artifactory/some.id \
-Dartifact=groupId:artifactId:1.1.1
Run Code Online (Sandbox Code Playgroud)
不传输用户名。我可以在调试输出中看到,调用时BasicRepositoryConnector没有用户名/密码组合。
所以问题是 - 是否可以调用一个插件,以便执行任何使 Maven 考虑使用其设置文件中声明的身份验证的过程?
我正在尝试在 docker 中构建一个开源项目,并希望节省构建时间,因此我尝试使用mvn dependency:go-offline,它会下载 maven-surefire-plugin 本身。
之后运行的mvn -o clean package结果是
[错误] 无法在项目 oxalis-api 上执行目标 org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test (default-test):执行目标 org.apache.maven 的默认测试.plugins:maven-surefire-plugin:3.0.0-M4:测试失败:插件org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4或其依赖项之一无法解析:无法访问离线模式下的apache.snapshots ( http://repository.apache.org/snapshots/ ) 并且之前尚未从中下载工件 org.codehaus.plexus:plexus-utils:jar:1.1 。-> [帮助1]
(我启用了快照存储库,因为 maven-dependency-plugin 对于多模块项目存在严重问题)
POM 包括
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Run Code Online (Sandbox Code Playgroud)
如上所述,该插件本身在离线后确实存在于我的存储库中。