我需要在Jenkins中编译使用Netbeans(7.2)创建的webapp,并且出现错误,指示需要将此参数传递给Ant:

-Dj2ee.server.home=<app_server_installation_directory>


我想在Windows和Linux中编译不依赖Tomcat或Glassfish的项目。可能吗?

最佳答案

解决方案是在build.xml Ant脚本中创建-pre-build任务,以下载Tomcat(或Glassfish)并将j2ee.server.home依赖项设置为正确的库路径。

<target name="-post-clean">
    <deltree dir="download" />
    <deltree dir="temp" />
</target>

<!--<target name="-pre-init" depends="check-dependencies" if="tomcat.present">-->
<target name="-pre-init">
    <property name="custom-tomcat-version" value="apache-tomcat-7.0.33" />

    <mkdir dir="temp"/>
    <get src="http://apache.rediris.es/tomcat/tomcat-7/v7.0.33/bin/apache-tomcat-7.0.33.zip" dest="temp/${custom-tomcat-version}.zip"/>

    <unzip dest="download/image" src="temp/${custom-tomcat-version}.zip">
        <patternset>
            <include name="apache-tomcat-7.*/lib/*"/>
        </patternset>
        <mapper>
            <globmapper from="apache-tomcat-7.*/lib/*" to="*"/>
        </mapper>
    </unzip>

    <!-- NB Ant script requieres this propertie to be assigned -->
    <property name="j2ee.server.home" value="download/image/${custom-tomcat-version}"/>
</target>


ien!
它就像一个魅力!

10-05 23:01