我有一个多模块maven项目。在父级上构建POM应构建所有子级模块,最后构建一个子模块,用于准备可执行jar。最后一个模块包含一个运行可执行文件的ant脚本,当从父项运行时不起作用,但是当子项的POM独立运行时,它将起作用。我假设问题是maven类路径。
POM的解剖部分是:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<!-- Clean execution is here-->
<execution>
<id>compile</id>
<phase>package</phase>
<configuration>
<target>
<!-- I have tried commenting out the following 4 lines but this does not work.-->
<property name="compile_classpath" refid="maven.compile.classpath" />
<property name="runtime_classpath" refid="maven.runtime.classpath" />
<property name="test_classpath" refid="maven.test.classpath" />
<property name="plugin_classpath" refid="maven.plugin.classpath" />
<property name="buildConfig" value="${buildConfig}" />
<property name="buildversion" value="${currentVersion}" />
<ant antfile="${basedir}/ANT FILE NAME.xml">
<target name="all" />
</ant>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Ant脚本包含以下行:
<target name="generate.scripts" depends="" description="generate scripts">
<mkdir dir="${distdir.product}" />
<mkdir dir="${distdir.product}/bin" />
<exec executable="bin/start.bat" dir="." failonerror="true">
<arg line="-server -createscript ${distdir.product}/bin/startserver.bat" />
</exec>
失败了:
Cannot run program "bin\start.bat" (in directory "CORRECT_DIRECTORY"): CreateProcess error=2, The system cannot find the file specified
有什么想法吗?
答案 0 :(得分:1)
尝试使用以下exec版本:
<exec executable="cmd" dir="${basedir}/bin" failonerror="true">
<arg value="/c" />
<arg value="start.bat" />
<arg value="-server" />
<arg value="-createscript" />
<arg value="${distdir.product}/bin/startserver.bat" />
</exec>