All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.j2ee.maven2.mda.build.xml.vsl Maven / Gradle / Ivy

The newest version!
<?xml version="1.0" encoding="UTF-8"?>
<!-- This ant build file builds and deploys an andromda application,
generates code for a project (using androMDA mvn install),
and formats the code using an import beautifier.
Customize as necessary - it is generated once only, when the project is created. -->
<project name="${applicationId}" default="all" basedir=".">
  <description>Create and deploy AndroMDA Application</description>
  <!-- set global properties for this build in build.properties file -->
  <property environment="env"/>
  <property file="build.properties"/>
  <property name="build" location="build"/>

  <!-- These environment variables must be set because we are running maven (mvn) from the command line:
  M2_REPO = Maven2 repository directory
  M2_HOME = Maven2 home installation directory
  MAVEN_OPTS = Command line options when running maven. Suggested: -XX:MaxPermSize=128m -Xmx512m
  Reference: http://www.andromda.org/index.php?option=com_content&view=article&id=105:environment-setup&catid=42:getting-started-java&Itemid=89 -->
  <property name="m2repo" value="${env.M2_REPO}"/>
  <property name="m2home" value="${env.M2_HOME}"/>
  <property name="m2opts" value="${env.MAVEN_OPTS}"/>

#if ($cxf)
  <path id="cxf.classpath">
    <pathelement location="${m2repo}/org/apache/cxf/cxf-bundle/${cxf.version}/cxf-bundle-${cxf.version}.jar"/>
    <pathelement location="${m2repo}/commons-lang/commons-lang/2.6/commons-lang-2.6.jar"/>
    <fileset dir="${m2repo}/org/andromda/thirdparty/jaxb-commons">
        <include name="**/*.jar"/>
        <exclude name="**/*-sources.jar"/>
        <exclude name="**/*-javadoc.jar"/>
    </fileset>
  </path>
  <path id="project.classpath">
    <path refid="cxf.classpath"/>
    <pathelement location="${m2repo}/log4j/log4j/1.2.16/log4j-1.2.16.jar"/>
    <pathelement location="${m2repo}/junit/junit/4.10/junit-4.10.jar"/>
    <pathelement location="${m2repo}/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar"/>
    <pathelement location="${m2repo}/commons-beanutils/commons-beanutils-core/1.8.3/commons-beanutils-1.8.3.jar"/>
#if ($spring || $hibernate)
    <pathelement location="${m2repo}/org/hibernate/hibernate/${hibernate.version}/hibernate-${hibernate.version}.jar"/>
    <pathelement location="${m2repo}/org/springframework/spring/${spring.version}/spring-${spring.version}.jar"/>
#elseif ($cxf)
    <pathelement location="${m2repo}/org/springframework/spring/${spring.version}/spring-${spring.version}.jar"/>
#end
#if ($ejb)
    <pathelement location="${m2repo}/jboss/jboss-j2ee/4.2.2.GA/jboss-j2ee-4.2.2.GA.jar"/>
#end
  </path>

#end
  <target name="init">
    <!-- Create the time stamp for logging purposes and log file renaming -->
    <tstamp>
        <format property="TODAY" pattern="yyyyMMdd"/>
        <format property="THIS_HOUR" pattern="yyyyMMddkk"/>
        <format property="DAY" pattern="yyMMdd" locale="en"/>
        <format property="NOW" pattern="HHmmss" locale="en"/>
    </tstamp>
    <echo message="m2repo=${m2repo}"/>
    <echo message="m2home=${m2home}"/>
  </target>

  <target name="clean" depends="init"
        description="clean the target project generated source code" >
    <!-- This duplicates the functionality of mvn clean, but allows for fine-grained control. -->
    <echo message="Delete the logs project=${project}"/>
    <delete includeEmptyDirs="true" failonerror="false" quiet="false" verbose="true">
      <fileset dir="${project}">
        <include name="**/*.exc"/>
        <include name="**/*.log"/>
      </fileset>
    </delete>

    <echo message="Delete the generated code"/>
    <!-- Delete all generated src and CXF files. -->
    <delete includeEmptyDirs="true" failonerror="${FOE}" quiet="false" verbose="true">
      <fileset dir="${andromda.project}">
        <include name="**/*.class"/>
        <include name="common/target/src/**/*.java"/>
        <include name="common/**/*.ref"/>
        <include name="core/target/src/**/*.java"/>
        <include name="core/**/*.ref"/>
#if ($cxf)
        <include name="CXF/target/src/**/*.*"/>
        <include name="CXF/**/WEB-INF/classes/**/*"/>
        <include name="CXF/**/WEB-INF/wsdl/**/*"/>
#end
        <include name="webservice/**/*.ref"/>
        <include name="webservice/target/src/**/*.java"/>
      </fileset>
    </delete>
  </target>

  <target name="cleanWSDL" depends="init"
          description="clean the Implementation wsdl and xsd files" >
    <echo message="Delete the wsdl and xsd files from ${andromda.project}"/>
    <delete includeEmptyDirs="true" failonerror="${FOE}" quiet="false" verbose="true">
      <fileset dir="${andromda.project}">
        <include name="webservice/src/main/webapp/**/*.wsdl"/>
        <include name="webservice/src/main/webapp/**/*.xsd"/>
        <include name="webservice/src/main/webapp/**/*.xjb"/>
        <include name="webservice/src/main/webapp/**/web*.xml"/>
        <include name="webservice/src/main/webapp/**/applicationContext*.xml"/>
        <include name="webservice/src/main/webapp/**/index*.html"/>
      </fileset>
    </delete>
  </target>

  <target name="cleanImpl" depends="init"
          description="clean the Implementation source code" >
    <echo message="Delete the implementation code"/>
    <delete includeEmptyDirs="true" failonerror="${FOE}" quiet="false" verbose="true">
      <fileset dir="${andromda.project}">
        <!-- Delete all impl files, for testing purposes. Comment out after testing complete -->
        <include name="common/src/**/*.*"/>
        <include name="core/src/**/*.*"/>
#if ($cxf)
        <include name="CXF/src/**/*.*"/>
        <!--include name="CXF/src/main/webapp/**/*.*"/-->
#end
        <include name="webservice/**/buildWS*.xml"/>
        <include name="webservice/src/**/*.*"/>
        <!--exclude name="webservice/src/**/*Jetty*.java"/>
        <exclude name="webservice/**/applicationContextSS*.xml"/-->
      </fileset>
    </delete>
  </target>

  <target name="gen" depends="init"
        description="generate source from cartridge using AndroMDA" >
    <move toDir="${project}/mda/logs" failonerror="${FOE}" preservelastmodified="true" verbose="true">
      <fileset dir="${project}/mda">
        <include name="*.exc"/>
        <include name="*.log"/>
      </fileset>
    </move>
    <!-- Command output displayed in the console window and in the andromda.log file, plus log file for each cartridge. -->
    <echo message="Running mvn ${offline} install from ${andromda.project}"/>
    <tstamp>
      <format property="timestamp" pattern="MMddHHmmss"/>
    </tstamp>
    <record name="${project}/mda/mvn${timestamp}.log" action="start" append="false"/>
    <!-- Change dir to ${project}/mda if you only want to generate code and beautify and compile. Code is not packaged by maven.. -->
    <exec dir="${andromda.project}" failonerror="${FOE}" executable="cmd.exe" vmlauncher="false">
      <!--output="${project}/androant.log" error="${project}/androant.log"-->
      <!-- not sure why the extra / is needed here, but it misses the one on the end of m2home -->
      <arg line="/c ${m2home}/bin/mvn.bat ${offline} install"/>
    </exec>
    <!-- If using separate Eclipse projects, log files can be examined from within Eclipse. -->
    <move preservelastmodified="true" failonerror="${FOE}" toDir="${project}/mda" verbose="true">
      <fileset dir="${project}">
        <include name="*.log"/>
        <include name="*.exc"/>
        <exclude name="andromda.log"/>
      </fileset>
    </move>
    <echo message="mvn ${offline} install complete"/>
    <record name="${project}/mda/mvn${timestamp}.log" action="stop"/>
    <!-- Rename log file so that it won't be automatically overwritten on multiple runs -->
    <move file="${project}/mda/andromda.log"
      tofile="${project}/mda/andromda${timestamp}.log" failonerror="false" verbose="true" preservelastmodified="true"/>
#if ($webservice)
    <move file="${project}/mda/andromda-webservice.log"
      tofile="${project}/mda/andromda-webservice${timestamp}.log" failonerror="false" verbose="true" preservelastmodified="true"/>
#end
    <move file="${project}/mda/andromda-java.log"
      tofile="${project}/mda/andromda-java${timestamp}.log" failonerror="false" verbose="true" preservelastmodified="true"/>
  </target>
#if ($cxf)

  <target name="buildWS" depends="init"
        description="Run java2wsdl and wsdl2java CXF utilities against generated code, targeting the CXF project">
    <!-- Run CXF wsdl2java and java2wsdl webservice generation -->
    <record name="${project}/webservice/wsgen${NOW}.log" action="start" append="false"/>
    <ant antfile="${andromda.project}/webservice/buildWSNew.xml" target="wsgenall"/>
    <!-- Jaxb generated package-info.java files cause the beautifier to fail formatting imports. -->
    <copy todir="${andromda.project}/CXF/target/src" overwrite="true" preservelastmodified="true" verbose="true" failonerror="${FOE}">
        <fileset dir="${andromda.project}/common/target/src">
          <include name="**/package-info.java"/>
        </fileset>
    </copy>
    <record name="${project}/webservice/wsgen${NOW}.log" action="stop"/>
    <move file="${project}/mda/wsgen*.log"
        todir="${project}/mda/logs" failonerror="false" verbose="true" preservelastmodified="true"/>
  </target>
#end

  <!-- Refreshes and builds the generated project within Eclipse. To run the eclipse tasks, ant must run with the same
  JVM as Eclipse (no fork). Open the Ant View: Window -> Show View -> Other... -> Ant -> Ant.
  Drag this build.xml file into the Ant View panel. Select the build script, and
  -> Run/Debug... JRE: Run in same JRE as workspace. Also set Refresh upon completion: Project containing
  the selected resource. Double click the build script to run. Settings will be retained if build file is deleted.-->
  <!-- Assumes application id = Eclipse project name. Can be changed if needed -->
  <target name="eclipse" depends=""
    description="Refresh and incremental build of Eclipse projects (requires Eclipse JRE)">
    <echo message="Refreshing and building project ${application.id}-mda"/>
    <eclipse.refreshLocal resource="${application.id}-mda" depth="infinite"/>
    <echo message="Refreshing and building project ${application.id}-common"/>
    <mkdir dir="${andromda.project}/common/target/src/main/java"/>
    <mkdir dir="${andromda.project}/common/src/main/java"/>
    <mkdir dir="${andromda.project}/common/target/classes"/>
    <eclipse.refreshLocal resource="${application.id}-common" depth="infinite"/>
    <eclipse.incrementalBuild project="${application.id}-common"/>
    <!--javac destdir="${andromda.project}/common/target/classes" source="1.5" target="1.5" debug="true" failonerror="false">
        <src path="${andromda.project}/common/src/main/java"/>
        <src path="${andromda.project}/common/target/src/main/java"/>
        <classpath>
            <pathelement location="${andromda.project}/common/target/classes"/>
            <path refid="project.classpath"/>
        </classpath>
    </javac-->
    <echo message="Refreshing and building project ${application.id}-core"/>
    <mkdir dir="${andromda.project}/core/target/src/main/java"/>
    <mkdir dir="${andromda.project}/core/src/main/java"/>
    <mkdir dir="${andromda.project}/core/target/classes"/>
    <eclipse.refreshLocal resource="${application.id}-core" depth="infinite"/>
    <eclipse.incrementalBuild project="${application.id}-core"/>
    <!--javac destdir="${andromda.project}/core/target/classes" source="1.5" target="1.5" debug="true" failonerror="false">
        <src path="${andromda.project}/core/src/main/java"/>
        <src path="${andromda.project}/core/target/src/main/java"/>
        <classpath>
            <pathelement location="${andromda.project}/core/target/classes"/>
            <pathelement location="${andromda.project}/common/target/classes"/>
            <path refid="project.classpath"/>
        </classpath>
    </javac-->
#if ($web)
    <echo message="Refreshing and building project ${application.id}-web"/>
    <mkdir dir="${andromda.project}/web/src/main/java"/>
    <mkdir dir="${andromda.project}/web/target/src/main/java"/>
    <mkdir dir="${andromda.project}/web/src/main/webapp/WEB-INF/classes"/>
    <eclipse.refreshLocal resource="${application.id}-webservice" depth="infinite"/>
    <eclipse.incrementalBuild project="${application.id}-webservice"/>
    <!--javac destdir="${andromda.project}/web/src/main/webapp/WEB-INF/classes" source="1.5" target="1.5" debug="true" failonerror="false">
        <src path="${andromda.project}/web/src/main/java"/>
        <src path="${andromda.project}/web/target/src/main/java"/>
        <classpath>
            <pathelement location="${andromda.project}/core/target/classes"/>
            <pathelement location="${andromda.project}/common/target/classes"/>
            <path refid="project.classpath"/>
            <pathelement location="${andromda.project}/web/src/main/webapp/WEB-INF/classes"/>
        </classpath>
    </javac-->
#end
#if ($webservice)
    <echo message="Refreshing and building project ${application.id}-webservice"/>
    <mkdir dir="${andromda.project}/webservice/src/main/java"/>
    <mkdir dir="${andromda.project}/webservice/target/src/main/java"/>
    <mkdir dir="${andromda.project}/webservice/src/main/webapp/WEB-INF/classes"/>
    <eclipse.refreshLocal resource="${application.id}-webservice" depth="infinite"/>
    <eclipse.incrementalBuild project="${application.id}-webservice"/>
    <!--javac destdir="${andromda.project}/webservice/src/main/webapp/WEB-INF/classes" source="1.5" target="1.5" debug="true" failonerror="false">
        <src path="${andromda.project}/webservice/src/main/java"/>
        <src path="${andromda.project}/webservice/target/src/main/java"/>
        <classpath>
            <pathelement location="${andromda.project}/core/target/classes"/>
            <pathelement location="${andromda.project}/common/target/classes"/>
            <path refid="project.classpath"/>
            <pathelement location="${andromda.project}/webservice/src/main/webapp/WEB-INF/classes"/>
            <pathelement location="${m2repo}/org/eclipse/jetty/jetty-server/${jetty.version}/jetty-server-${jetty.version}.jar"/>
        </classpath>
    </javac-->
#end
    <echo message="Refreshing and building project ${application.id}-app"/>
    <!--eclipse.refreshLocal resource="${application.id}-app" depth="infinite"/-->
#if ($cxf)
    <echo message="Refreshing and building project ${application.id}-CXF"/>
    <mkdir dir="${andromda.project}/CXF/src/main/java"/>
    <mkdir dir="${andromda.project}/CXF/target/src/main/java"/>
    <mkdir dir="${andromda.project}/CXF/src/main/webapp/WEB-INF/classes"/>
    <eclipse.refreshLocal resource="${application.id}-CXF" depth="infinite"/>
    <eclipse.incrementalBuild project="${application.id}-CXF"/>
    <!--javac destdir="${andromda.project}/CXF/src/main/webapp/WEB-INF/classes" source="1.5" target="1.5" debug="true" failonerror="false">
        <src path="${andromda.project}/CXF/src/main/java"/>
        <src path="${andromda.project}/CXF/target/src/main/java"/>
        <classpath>
            <path refid="project.classpath"/>
            <pathelement location="${andromda.project}/CXF/src/main/webapp/WEB-INF/classes"/>
        </classpath>
    </javac-->
#end
    <!-- Comment out above, uncomment below if using separate Eclipse projects -->
    <!--echo message="Refreshing and building project ${applicationId}"/>
    <eclipse.refreshLocal resource="${application.id}" depth="infinite"/>
    <eclipse.incrementalBuild project="${application.id}"/-->
  </target>

  <target name="all" depends="init">
    <!-- Uncomment to delete generated code (clean start) -->
    <antcall target="clean"/>
    <!-- Delete WSDLs and XSD files -->
    <antcall target="cleanWSDL"/>
    <!-- Uncomment to delete implementation code, including changes made outside of SCM -->
    <!--antcall target="cleanImpl"/-->
    <antcall target="gen"/>
#if ($cxf)
    <!-- Run CXF wsdl2java and java2wsdl webservice generation. buildWS.xml is not overwritten>
    <ant antfile="${andromda.project}/webservice/buildWSNew.xml" target="wsgenall"/ -->
#end
    <!-- Comment out if not using Eclipse or running in separate JVM -->
    <antcall target="eclipse"/>
  </target>
</project>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy