刚刚安装了 Apache Ant 和 Maven Ant 任务。我的项目中有一个 build.xml,我试图将其作为 Ant Build 运行,但是当我尝试运行它时,它返回以下内容:
Unknown argument: -build
Buildfile: C:\Users\arempel\workspace\cis\cisbackend\build.xml
[mvn:dependencies] [INFO] snapshot choicehotels.util.io:choice-io:0.0.3-SNAPSHOT: checking for updates from nexus
[mvn:dependencies] [WARNING] repository metadata for: 'snapshot choicehotels.util.io:choice-io:0.0.3-SNAPSHOT' could not be retrieved from repository: nexus due to an error: Error transferring file: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
[mvn:dependencies] [INFO] Repository 'nexus' will be blacklisted
local-properties-found:
local-properties-not-found:
[echo] local.properties file not found in ../.., ../, or C:\Users\arempel/eclipse_properties
build-web-extras-found:
build-web-extras-not-found:
[echo] build_web_extras.properties file not found in ../.., ../, or C:\Users\arempel/eclipse_properties
report-local-properties:
-verify_local_properties:
BUILD FAILED
C:\Users\arempel\workspace\cis\cisbackend\build.xml:47: local.properties or build_wewb_extras.properties file not found
Total time: 1 second
我不知道从哪里开始寻找解决这个问题。它可能是一个环境变量,但我在 Users\myusername\apache-ant-1.9.1 下添加了 Ant,所以我不确定我需要做什么。
编辑:添加了 build.xml
<project name="cisbackend" default="local" basedir="."
xmlns:mvn="antlib:org.apache.maven.artifact.ant">
<!-- ===================== Property Definitions =========================== -->
<!-- locate the local.properties and build_web_extras.properties files within the workspace -->
<import file="../locate-local-properties.xml" />
<property file="${local.properties.dir}/build_web_extras.properties"/>
<property environment="env"/>
<property name="app.name" value="cisbackend"/>
<property name="compile.debug" value="true"/>
<property name="compile.deprecation" value="false"/>
<property name="compile.optimize" value="false"/>
<property name="compile.home" value="target"/>
<property name="package.home" value="target/package"/>
<property name="resources" value="src/main/resources" />
<property name="xsl.home" value="${resources}/xsl"/>
<property name="images.home" value="${resources}/images"/>
<property name="dist.home" value="target/dist"/>
<!-- -->
<macrodef name="runmvn">
<element name="args" optional="yes"/>
<sequential>
<mvn:mvn mavenHome="${env.MAVEN_HOME}" fork="true" dir="${basedir}" failonerror="true">
<args /> <!-- additional arg elements specified by the caller-->
</mvn:mvn>
</sequential>
</macrodef>
<!-- Set up the compiler CLASSPATH -->
<mvn:dependencies filesetId="maven.dependencies" useScope="compile">
<pom file="pom.xml"/>
</mvn:dependencies>
<path id="compile.classpath">
<fileset refid="maven.dependencies" />
</path>
<target name="-verify_local_properties" depends="report-local-properties">
<fail message="local.properties or build_wewb_extras.properties file not found" unless="configuration-is-valid" />
</target>
<!-- ==================== Clean Target ==================================== -->
<target name="clean">
<runmvn>
<args>
<arg value="clean" />
</args>
</runmvn>
</target>
<!-- ==================== Compile Target ================================== -->
<target name="-compile">
<runmvn>
<args>
<arg value="compile" />
</args>
</runmvn>
</target>
<!-- ==================== Build Target ==================================== -->
<target name="-build" depends="-compile">
<mkdir dir="${package.home}/lib"/>
<!-- Copy jar files into the package directory -->
<jar destfile="${package.home}/lib/cisbackend.jar"
basedir="${compile.home}/classes">
<exclude name="*"/>
</jar>
<copy todir="${package.home}/lib" flatten="true">
<fileset refid="maven.dependencies" />
</copy>
<!-- Copy property files and stylesheets -->
<copy todir="${package.home}/classes">
<fileset dir="target/classes" includes="*"/>
</copy>
<!-- Copy scripts -->
<copy todir="${package.home}">
<fileset dir="src/scripts"/>
</copy>
<copy todir="${package.home}/control">
<fileset dir="src/control"/>
</copy>
<copy todir="${package.home}/xsl">
<fileset dir="${xsl.home}"/>
</copy>
<copy todir="${package.home}/images">
<fileset dir="${images.home}"/>
</copy>
</target>
<!-- ==================== Replace Target ================================= -->
<target name="-replace">
<echo message="Replacing tokens found in property file ${replace.file}"/>
<!-- Copy environment specific configuration files -->
<copy todir="${package.home}/${replace.dir}">
<fileset dir="src/config"/>
</copy>
<replace dir="${package.home}/${replace.dir}"
replaceFilterFile="${replace.file}"
summary="yes"/>
</target>
<!-- ==================== Dist Target ===================================== -->
<target name="-dist">
<mkdir dir="${dist.home}"/>
<!-- For some reason ANT doesn't figure out the TAR file needs to be
changed so delete it first -->
<delete file="${dist.home}/cisbackend.tar"/>
<!-- Create application TAR file -->
<tar tarfile="${dist.home}/cisbackend.tar">
<tarfileset dir="${package.home}" mode="755">
<include name="*.sh"/>
</tarfileset>
<tarfileset dir="${package.home}">
<include name="**"/>
<exclude name="*.sh"/>
</tarfileset>
</tar>
<mvn:install file="${package.home}/lib/cisbackend.jar">
<pom file="pom.xml"/>
</mvn:install>
</target>
<!-- ==================== Deploy Target =================================== -->
<target name="-deploy" depends="-dist">
<!-- Deploy the TAR file -->
<exec executable="/cis/cisdev/bin/copyanddeploy">
<arg value="${version}"/>
<arg file="${dist.home}/cisbackend.tar"/>
</exec>
</target>
<target name="hudson.copytodeploy">
<property file="target/classes/version.properties" prefix="project"/>
<copy todir="${build.deploy.dir}" verbose="true">
<fileset dir="${dist.home}" includes="*.war,*.tar"/>
<globmapper from="*" to="*.${project.version.major}-${project.version.minor}-${project.version.build}" />
</copy>
</target>
<!-- ==================== Local Targets =================================== -->
<target name="-local_replace" depends="-build">
<!-- define default for dev.replace.file in case developer
does not define in build_web_extras.properties -->
<property name="cisbackend.replace.file" value="dev1.properties" />
<!-- replace tokens specified in the developer's local.properties file -->
<antcall target="-replace">
<param name="replace.file" value="${local.properties.dir}/local.properties"/>
<param name="replace.dir" value="config"/>
</antcall>
<!-- replace any additional tokens using the file
specified by the cisbackend.replace.file property in the developer's
build_web_extras.properties file -->
<antcall target="-replace">
<param name="replace.file" value="${cisbackend.replace.file}"/>
<param name="replace.dir" value="config"/>
</antcall>
</target>
<target name="local_clean" depends="clean"/>
<!-- This target should be used for creating a build on your local machine. -->
<target name="local" description="Build the project for your machine"
depends="-verify_local_properties, local_clean, -local_replace, -dist" />
<!-- ==================== Distribution Targets ============================ -->
<target name="-dist-replace" depends="-build">
<antcall target="-replace">
<param name="replace.file" value="dev1.properties"/>
<param name="replace.dir" value="config-dev1"/>
</antcall>
<antcall target="-replace">
<param name="replace.file" value="dev2.properties"/>
<param name="replace.dir" value="config-dev2"/>
</antcall>
<antcall target="-replace">
<param name="replace.file" value="dev3.properties"/>
<param name="replace.dir" value="config-dev3"/>
</antcall>
<antcall target="-replace">
<param name="replace.file" value="qa2.properties"/>
<param name="replace.dir" value="config-qa2"/>
</antcall>
<antcall target="-replace">
<param name="replace.file" value="qa1.properties"/>
<param name="replace.dir" value="config-qa1"/>
</antcall>
<antcall target="-replace">
<param name="replace.file" value="prod1.properties"/>
<param name="replace.dir" value="config-prod1"/>
</antcall>
</target>
<target name="-dist_clean" depends="clean"/>
<!-- This target should be used for creating a release build. -->
<target name="build.release" description="Build a release"
depends="-dist_clean, -dist-replace, -dist"/>
</project>