【问题标题】:Ant build fails as part of multi-module maven buildAnt 构建作为多模块 Maven 构建的一部分失败
【发布时间】:2013-04-10 14:17:28
【问题描述】:

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

有什么想法吗?

【问题讨论】:

    标签: maven ant maven-antrun-plugin


    【解决方案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>
    

    【讨论】:

    • 现在独立构建也失败了。 "exec returned: 1" 我会在命令行上试一试,明天看看错误是什么。
    • 确保dir="." 正确。似乎有点奇怪。会不会是:dir="${basedir}"
    • 以下工作:
    猜你喜欢
    • 2014-10-30
    • 2016-10-30
    • 1970-01-01
    • 2022-11-01
    • 1970-01-01
    • 2013-11-09
    • 1970-01-01
    • 1970-01-01
    • 2021-04-27
    相关资源
    最近更新 更多