1

我有一个多模块 Maven 项目。在父级上构建 POM 应该构建所有子模块,最后构建一个准备可执行 jar 的子模块。最后一个模块包括一个运行可执行文件的 ant 脚本,当从父级运行时将不起作用,但在子级的 POM 单独运行时将起作用。我认为问题是一个 Maven 类路径。

POM 的 antrun 部分是:

<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

有任何想法吗?

4

1 回答 1

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>
于 2013-04-10T16:17:57.813 回答