我和maven一起工作。
如此链接中所示:http://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-artifacts.html(第二种情况),如果工件被列为依赖项,我们可以删除存在的标记。因为artifactItem的版本将默认为依赖项的版本。
但使用配置文件时并非如此。
我使用了两个配置文件,其中我添加了依赖项。我的pom是这样的:
<profile>
<id>buildDependency</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>maven.dependency</name>
<value>true</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.marshy</groupId>
<artifactId>marshy1</artifactId>
<version>1.1.0.5</version>
</dependency>
现在,如果我从认为它将从此处获取值的标记中移除标记,则它会抛出错误并且表示&#34;无法收集.......&#34; < / p>
我如何才能为个人资料工作?
答案 0 :(得分:0)
我编辑了示例,以在profile dependencies标记内指定junit依赖项。请参阅此示例pom.xml
。我这样做没有遇到任何问题,所以你的pom中可能会有一个不同的问题(你只发布了一部分)。
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>build-dependency-example</artifactId>
<groupId>org.example</groupId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
<destFileName>optional-new-name.jar</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/wars</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>buildDependency</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>maven.dependency</name>
<value>true</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>