我想知道在使用maven依赖插件的dependency-unpack目标时是否有办法强制存在依赖关系以解包。我正在使用下面的配置,问题是如果pom的依赖项部分中没有为“$ {properties.artifactId}”指定依赖项,即使没有任何解包,构建也会继续。它总是在测试阶段后期失败但如果构建在没有依赖性时可能失败将会更容易。那么有人知道可以强制执行的方式吗?
由于
墩
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-properties</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeArtifactIds>${properties.artifactId}</includeArtifactIds>
<outputDirectory>${project.build.directory}</outputDirectory>
<includes>${properties.file.name}</includes>
</configuration>
</execution>
</executions>
</plugin>
答案 0 :(得分:0)
maven-enforcer-plugin的几个执行应该这样做。你需要在依赖插件之前运行一个,以确保$ {properties.artifactId}有一个值,然后在依赖插件之后运行另一个以确保目标位置中有文件。这是想法,根据您的要求进行修改。
如果those available不太合适,您也可以编写自己的规则。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>fillInTheVersion</version>
<executions>
<execution>
<id>enforce-config-properties</id>
<phase>validate</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>properties.artifactId</property>
<message><![CDATA[### Missing property 'properties.artifactId': the artifact that ....]]></message>
</requireProperty>
</rules>
</configuration>
</execution>
<execution>
<id>enforce-files-exist</id>
<phase>process-resources</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireFilesExist>
<files>
<file>${project.build.directory}/${properties.artifactId}</file>
</files>
<message><![CDATA[### Did not find unpacked artifact ...]]></message>
</requireFilesExist>
</rules>
</configuration>
</execution>
</executions>
</plugin>