作为多模块maven构建的一部分,Ant构建失败



我有一个多模块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>

And failed with:

Cannot run program "binstart.bat" (in directory "CORRECT_DIRECTORY"): CreateProcess error=2, The system cannot find the file specified

任何想法?

试试下面的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>

相关内容

  • 没有找到相关文章

最新更新