我正在使用maven多模块项目。简化的Dim f As New frmOrder(con, False, False, , orderNum)
f.MdiParent = Me.Owner
f.Show()
(pom.xml
下方)如下所示: -
full-build
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<groupId>com.eros</groupId>
<artifactId>full-build</artifactId>
<version>0.001-SNAPSHOT</version>
<name>full-build</name>
<profiles>
<profile>
<id>build-only</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>../../main</module>
</modules>
</profile>
<profile>
<id>copy-only</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<!-- collector -->
<copy file="../collector-framework/collector/target/collector-${project.version}.jar"
tofile="./target/collector/collector-${project.version}.jar"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
内的简化pom.xml
如下所示: -
main
每当我尝试使用<?xml version="1.0" encoding="UTF-8"?>
<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.eros</groupId>
<artifactId>main</artifactId>
<version>0.001-SNAPSHOT</version>
<packaging>pom</packaging>
<name>main</name>
<modules>
<module>collector-framework</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[1.8,)</version>
<message>*** This project requires JDK 1.8/J2SE 8 or later. ***</message>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
执行上述项目时,都会跳过collector-framework项目并且构建失败并显示错误
mvn clean install -T 4
如果我只做Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (default) on project full-build: An Ant BuildException has occured: Warning: Could not find file /Users/tuk/code/github/eros/main/collector-framework/collector/target/collector-0.001-SNAPSHOT.jar to copy.
[ERROR] around Ant part ...<copy file="../collector-framework/collector/target/collector-0.001-SNAPSHOT.jar" tofile="./target/collector/collector-0.001-SNAPSHOT.jar"/>... @ 4:143 in /Users/tuk/code/github/eros/main/full-build/target/antrun/build-main.xml
,一切正常。我认为这是因为ant-run在mvn clean install
模块执行完成之前运行。有人可以告诉我如何在{1}}等待主模块编译结束时进行并行构建吗?
答案 0 :(得分:0)
要解决此问题,我将collector-framework
的依赖关系添加到maven-antrun-plugin
,如下所示: -
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<dependencies>
<dependency>
<groupId>a.b.c</groupId>
<artifactId>collector</artifactId>
<version>0.001-SNAPSHOT</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<!-- collector -->
<copy file="../collector-framework/collector/target/collector-${project.version}.jar" tofile="./target/collector/collector-${project.version}.jar"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
上述更改使maven-antrun等到创建收集器jar。