我只需要将一个依赖项及其所有传递依赖项复制到指定的文件夹.我知道我可以用"excludeArtifactIds"排除工件,但我还需要排除那些工件的传递依赖性,显然"excludeArtifactIds"不能.
有办法做到这一点吗?
我在依赖globalmentor-core.jar中有一个JavaScript库,我在另一个项目中使用maven-dependency将JavaScript转移到web目录:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>unpack</id>
<phase>process-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.globalmentor</groupId>
<artifactId>globalmentor-core</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.outputDirectory}/com/guiseframework/assets/javascript</outputDirectory>
<includes>**/*.js</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这在命令行上运行得非常好.在Eclipse中使用m2eclipse我得到:
2/4/11 5:26:53 AM PST: Build errors for guiseframework; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:unpack (unpack) on project guiseframework: Error unpacking file: R:\java\trunk\globalmentor-core\target\classes to: R:\java\trunk\guiseframework\target\classes\com\guiseframework\assets\javascript
org.codehaus.plexus.archiver.ArchiverException: The source must not be a directory.
Run Code Online (Sandbox Code Playgroud)
我能找到的最接近的东西是http://jira.codehaus.org/browse/MDEP-187,有人声称他们将"很快提供琐碎的补丁.那是在2008年.
有没有解决这个问题,还是我被卡住了?
升级到maven 3后,我的程序集插件和程序集插件只需花费更多时间来复制内容.
是否有人已经遇到过这个问题,或者我需要做些什么才能使性能更快?
我很乐意在这里添加,我拥有的assebmly插件配置和使用的描述符,因为需要它.
谢谢
有一个具有以下结构的 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) 我有一个非常复杂的项目(大约100个模块),我想在其上运行mvn dependency:tree.它失败了,抱怨无法解决的依赖关系.否则该项目编制正常.所以我创建了我可以提出的最基本的项目,它仍然失败并出现同样的错误.显然要么我必须做一些非常基本的错误,或者maven-dependency-plugin还没有被任何人使用过.以下是测试项目的三个POM:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>root</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>foo</module>
<module>bar</module>
</modules>
</project>
Run Code Online (Sandbox Code Playgroud)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>foo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>
Run Code Online (Sandbox Code Playgroud)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>bar</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>foo</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
然后我mvn dependency:tree在顶级目录中发出以下命令并获得以下输出:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build …Run Code Online (Sandbox Code Playgroud) 我正在尝试从依赖jar文件中提取一些.exe文件,并将它们放在$ {project.build.directory}/classes /下.
但是当我执行时:
mvn clean编译依赖:unpack
我得到:
无法执行目标org.apache.maven.plugins:maven-dependency-plugin:2.10:unpack(default-cli)项目简单:需要artifact或artifactItems - > [帮助1
我已经验证了依赖项在我的本地存储库中可用.
在我的示例pom中,我使用junit作为示例,但无论我列出哪个依赖项,我都会得到相同的错误.
pom.xml中:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/classes/externaltools</outputDirectory>
<includes>**/*.txt</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Run Code Online (Sandbox Code Playgroud) 将maven-dependency-plugin它认为是未使用的依赖,当你在编译时产生警告编译标识.
[WARNING] Unused declared dependencies found:
[WARNING] org.foo:bar-api:jar:1.7.5:compile
Run Code Online (Sandbox Code Playgroud)
在某些情况下,此消息是误报,并且依赖性是可传递的.
问题:我如何识别我pom.xml的情况?
尝试使用名为simmetrics的项目:http : //sourceforge.net/projects/simmetrics/
尝试将项目作为maven 依赖项添加到POM文件中,如下所示:
<dependency>
<groupId>net.sf.simmetrics</groupId>
<artifactId>simmetrics</artifactId>
<version>1.6.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我还添加了存储库,如下所示:
<repository> <id>simmetrics.website</id>
<name>Simmetrics Website</name>
<url>http://sourceforge.net/projects/simmetrics/</url>
</repository>
Run Code Online (Sandbox Code Playgroud)
谁能指出我正确的方向,这似乎很愚蠢。
谢谢你的时间。
编辑
在其他地方找到它,但我似乎也无法访问它:https : //dev-iesl.cs.umass.edu/nexus/content/groups/public/
<repository>
<id>IESL Releases</id>
<name>IESL Repo</name>
<url>https://dev-iesl.cs.umass.edu/nexus/content/groups/public</url>
</repository>
<dependency>
<groupId>uk.ac.shef.wit.simmetrics</groupId>
<artifactId>simmetrics</artifactId>
<version>1.6.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
如果有人想知道是的,我正在使用其他各种 maven 依赖项,但之前从未经历过这种情况。
我想知道是否有办法从 maven 依赖项中删除版本号。
假设对于我的项目,我想commons-lang3 3.4使用 maven 依赖插件来获取:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我的 pom 配置说,它正在将依赖项提取到./lib我的项目内的目录中。
我想要实现的是从commons-lang3-3.4.jar. 它看起来像:
./lib/commons-lang3.jar
问题:有没有办法做这样的事情?
在这里指定 finalName 无济于事。
<build>
<finalName>${project.name}-testing</finalName>
</build>
Run Code Online (Sandbox Code Playgroud)
在我现有的配置之下:
<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>process-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${dir.javaLibs}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud) 我正在使用下面的命令通过命令行从 Nexus 下载一个 Maven jar。
call mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DrepoUrl=http://10.101.15.190:8081/nexus/content/repositories/releases/ -Dartifact=bits:update-service:1.0.3 -Ddest=Setups/Services/update-service.jar
Run Code Online (Sandbox Code Playgroud)
但我得到的是一个没有依赖关系的 jar。Maven 中已经有一个带有依赖项的 jar 名称update-service-1.0.4-jar-with-dependencies.jar
我尝试了以下方法:
call mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get -DrepoUrl=http://10.101.15.190:8081/nexus/content/repositories/releases/ -Dartifact=bits:update-service:1.0.3[:packaging[:jar]] -Ddest=Setups/Services/update-service.jar
Run Code Online (Sandbox Code Playgroud)
但它返回以下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.4:get (default-cli) on project standalone-pom: Couldn't download artifact: Missing:
[ERROR] ----------
[ERROR] 1) bits:update-service:packaging[:jar]]:1.0.3[
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=bits -DartifactId=update-service -Dversion=1.0.3[ -Dclassifier=jar]] -Dpackaging=packaging[ -Dfile=/path/to/file
[ERROR]
[ERROR] Alternatively, if you host your own …Run Code Online (Sandbox Code Playgroud)