0

Maven は、この ANT build.xml で行っていることを実行できますか。

  1. ソースコードと jar を取得して戦争をする
  2. ファイルの移動
  3. プロパティ ファイルの値に基づいてファイル内の値を変更する
  4. ファイルの削除
  5. サーバーへの SCP WAR

以下は私のANTビルドです。Mavenでこれをすべて行うことができるかどうか教えてください...ありがとう

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="build" name="Create Runnable Jar for Project DisasterReliefBatch with Jar-in-Jar Loader">
    <!--this file was created by Eclipse Runnable JAR Export Wizard-->
    <!--ANT 1.7 is required      
                               -->
    <property name="server.location" value="uftwfssh@6dvjvm01.uftwf.dev:/home/uftwfssh" />
    <path id="master-classpath">
        <fileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" />
    </path>


    <target name="movexml" depends="clean">
        <copy todir="${user.home}/uft-workspace/DisasterReliefBatch/bin" overwrite="true">
            <fileset dir="${user.home}/uft-workspace/DisasterReliefBatch/src" includes="*.xml" />
            <mapper type="flatten" />
        </copy>

        <replace file="${user.home}/uft-workspace/DisasterReliefBatch/bin/config.xml" value="defaultvalue" propertyFile="name.properties">
            <replacefilter token="os400dataSource.url" property="os400dataSource.url" />
            <replacefilter token="os400dataSource.username" property="os400dataSource.username" />
            <replacefilter token="os400dataSource.password" property="os400dataSource.password" />

            <replacefilter token="mysqldataSource.url" property="mysqldataSource.url" />
            <replacefilter token="mysqldataSource.username" property="mysqldataSource.username" />
            <replacefilter token="mysqldataSource.password" property="mysqldataSource.password" />
        </replace>

        <replace file="${user.home}/uft-workspace/DisasterReliefBatch/bin/log4j.xml" value="defaultvalue" propertyFile="name.properties">
            <replacefilter token="email.to" property="email.to" />
            <replacefilter token="email.SMTPHost" property="email.SMTPHost" />
        </replace>
    </target>

    <target name="clean">
        <delete dir="${user.home}/uft-workspace/DisasterReliefBatch/bin" />
    </target>

    <target name="compile" depends="movexml">
        <mkdir dir="${user.home}/uft-workspace/DisasterReliefBatch/bin" />

        <javac destdir="${user.home}/uft-workspace/DisasterReliefBatch/bin">
            <src path="${user.home}/uft-workspace/DisasterReliefBatch/src" />
            <classpath refid="master-classpath" />
        </javac>

    </target>

    <target name="build" depends="compile">
        <jar destfile="${user.home}/DRB.jar">
            <manifest>
                <attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader" />
                <attribute name="Rsrc-Main-Class" value="org.uftwf.batch.MainBatch" />
                <attribute name="Class-Path" value="." />
                <attribute name="Rsrc-Class-Path" value="./ commons-logging-1.1.1.jar mysql-connector-java-5.0.5.jar jt400Native.jar log4j-1.2.14.jar org.springframework.beans-3.0.6.RELEASE.jar org.springframework.core-3.0.6.RELEASE.jar org.springframework.jdbc-3.0.6.RELEASE.jar org.springframework.context-3.0.6.RELEASE.jar org.springframework.context.support-3.0.6.RELEASE.jar org.springframework.aspects-3.0.6.RELEASE.jar org.springframework.oxm-3.0.6.RELEASE.jar org.springframework.instrument.tomcat-3.0.6.RELEASE.jar commons-codec-1.4.jar httpclient-4.1.2.jar httpclient-cache-4.1.2.jar httpcore-4.1.2.jar httpmime-4.1.2.jar itext-xtra-5.1.3.jar itextpdf-5.1.3.jar jt400.jar junit-4.10.jar org.springframework.aop-3.0.6.RELEASE.jar org.springframework.asm-3.0.6.RELEASE.jar org.springframework.expression-3.0.6.RELEASE.jar org.springframework.instrument-3.0.6.RELEASE.jar org.springframework.jms-3.0.6.RELEASE.jar org.springframework.orm-3.0.6.RELEASE.jar org.springframework.test-3.0.6.RELEASE.jar org.springframework.transaction-3.0.6.RELEASE.jar org.springframework.web-3.0.6.RELEASE.jar org.springframework.web.portlet-3.0.6.RELEASE.jar org.springframework.web.servlet-3.0.6.RELEASE.jar org.springframework.web.struts-3.0.6.RELEASE.jar mail.jar mailapi.jar smtp.jar" />
            </manifest>

            <zipfileset src="${user.home}/jar-in-jar-loader.zip" />
            <fileset dir="${user.home}/uft-workspace/DisasterReliefBatch/bin" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="commons-logging-1.1.1.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="mysql-connector-java-5.0.5.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="jt400Native.jar" />
            <fileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch" includes="log4j-1.2.14.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.beans-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.core-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.jdbc-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.context-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.context.support-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.aspects-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.oxm-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.instrument.tomcat-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="commons-codec-1.4.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="httpclient-4.1.2.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="httpclient-cache-4.1.2.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="httpcore-4.1.2.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="httpmime-4.1.2.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="itext-xtra-5.1.3.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="itextpdf-5.1.3.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="jt400.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="junit-4.10.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.aop-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.asm-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.expression-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.instrument-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.jms-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.orm-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.test-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.transaction-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.web-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.web.portlet-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.web.servlet-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="org.springframework.web.struts-3.0.6.RELEASE.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="mail.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="mailapi.jar" />
            <zipfileset dir="${user.home}/uft-workspace/DisasterReliefBatch/lib" includes="smtp.jar" />
        </jar>


    </target>

    <target name="promote" depends="build">
        <input message="New version is going to be updated to 6dvjvm01 continue (y/n)?" validargs="y,n" addproperty="do.delete" />

        <condition property="do.abort">
            <equals arg1="n" arg2="${do.delete}" />
        </condition>

        <fail if="do.abort">Build aborted by user.</fail>

        <scp file="${user.home}/DRB.jar" todir="${server.location}" keyfile="${user.home}/.ssh/id_rsa" />
    </target>

    <target name="run" depends="build">
        <java jar="${user.home}/DRB.jar" fork="true" />
    </target>

    <target name="run-count" depends="build">
        <java jar="${user.home}/DRB.jar" fork="true">
            <arg value="count" />
        </java>
    </target>
</project>
4

2 に答える 2

1

うん。プロパティベースの注入は、Maven では「リソース フィルタリング」として知られています。http://www.sonatype.com/books/mvnref-book/reference/resource-filtering-sect-description.htmlを参照してください。

Maven プロジェクトでは、ファイルの移動が必要になることはめったにありません。規約に従うか、コンパイラ/war-assembly プラグインの追加の「ソース」パスを宣言するだけです。

私は maven を使用して war ファイルをサーバーに直接 scp したことはありませんが、このスレッドをリソースとして読み取ります: Maven copy local file to remote server using SSH

最後の努力として、maven には「antrun」プラグインもあり、必要に応じてカスタム ant タスクを実行できます。ただし、あなたの場合は必須ではありません。

于 2012-09-12T20:11:14.640 に答える