Skip to content

Commit

Permalink
Maven support
Browse files Browse the repository at this point in the history
- Dependencies are fetched using Maven
- Ant targets for Maven Central deployment
  • Loading branch information
ceari committed Jul 16, 2013
1 parent b9d191b commit c3f97e8
Show file tree
Hide file tree
Showing 26 changed files with 379 additions and 18 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Expand Up @@ -13,4 +13,8 @@ Thumbs.db

# Custom ant properties
#######################
etc/custom-build.properties
etc/custom-build.properties

# Dependencies fetched by Maven
echolot-app/lib
echolot-webcontainer/lib
160 changes: 154 additions & 6 deletions build.xml
Expand Up @@ -7,7 +7,7 @@
~ Version: MPL 1.1/GPL 2.0/LGPL 2.1
-->

<project name="echolot" default="dist">
<project name="echolot" default="dist" xmlns:artifact="antlib:org.apache.maven.artifact.ant">

<property name="dir.dist" value="dist"/>
<property name="dir.site" value="target/site"/>
Expand All @@ -24,6 +24,14 @@
<property name="demo.path" value="echolot-demo"/>
<property name="licensing.path" value="licensing"/>
<property name="documentation.path" value="documentation"/>

<!-- Minimize -->
<target name="minimize" depends="clean"
description="Removes all non-essential files, including Eclipse temporary/build output files">
<delete dir="${dir.build}"/>
<delete dir="${app.path}/lib"/>
<delete dir="${webcontainer.path}/lib"/>
</target>

<target name="clean" unless="skip.clean">
<delete dir="${dir.dist}"/>
Expand All @@ -33,35 +41,79 @@
<ant antfile="${demo.path}/build.xml" target="clean.module" inheritall="false" inheritrefs="false"/>
</target>

<!-- Dependencies -->
<target name="-check.dependencies">
<available file="${app.path}/lib/echo3-app-${echo.version}.jar" property="dependencies.present"/>
</target>

<target name="mvn.dependencies" depends="-mvn.inittasks"
description="Fetches the required dependencies from Maven Central into the lib dir">

<artifact:dependencies filesetId="app.dependency.fileset">
<dependency groupId="com.nextapp" artifactId="echo3-app" version="${echo.version}"/>
<dependency groupId="com.nextapp" artifactId="echo3-app" version="${echo.version}" classifier="sources"/>
<dependency groupId="com.nextapp" artifactId="echo3-webcontainer" version="${echo.version}"/>
<dependency groupId="com.nextapp" artifactId="echo3-webcontainer" version="${echo.version}" classifier="sources"/>
<dependency groupId="javax.servlet" artifactId="servlet-api" version="2.4"/>
<dependency groupId="javax.servlet" artifactId="servlet-api" version="2.4" classifier="sources"/>
</artifact:dependencies>

<artifact:dependencies filesetId="webcontainer.dependency.fileset">
<dependency groupId="javax.servlet" artifactId="servlet-api" version="2.4"/>
<dependency groupId="javax.servlet" artifactId="servlet-api" version="2.4" classifier="sources"/>
<dependency groupId="org.codehaus.jettison" artifactId="jettison" version="1.1"/>
<dependency groupId="org.codehaus.jettison" artifactId="jettison" version="1.1" classifier="sources"/>
<dependency groupId="com.thoughtworks.xstream" artifactId="xstream" version="1.4.4"/>
<dependency groupId="com.thoughtworks.xstream" artifactId="xstream" version="1.4.4" classifier="sources"/>
<dependency groupId="com.googlecode.jslint4java" artifactId="jslint4java" version="1.4.2"/>
<dependency groupId="junit" artifactId="junit" version="4.5"/>
</artifact:dependencies>

<copy todir="${app.path}/lib">
<fileset refid="app.dependency.fileset" />
<mapper type="flatten" />
</copy>

<copy todir="${webcontainer.path}/lib">
<fileset refid="webcontainer.dependency.fileset" />
<mapper type="flatten" />
</copy>
</target>

<target name="dependencies" depends="-check.dependencies" unless="dependencies.present"
description="Spot checks for dependency JARs availability and fetches via Maven Central if required">
<antcall target="mvn.dependencies"/>
</target>

<target name="generate" description="Call generation targets of all modules">
<ant antfile="${app.path}/build.xml" target="generate" inheritall="false" inheritrefs="false"/>
<ant antfile="${webcontainer.path}/build.xml" target="generate" inheritall="false" inheritrefs="false"/>
<ant antfile="${demo.path}/build.xml" target="generate" inheritall="false" inheritrefs="false"/>
</target>

<target name="build" description="Build echolot ">
<target name="build" depends="dependencies" description="Build echolot ">
<mkdir dir="dist"/>
<ant antfile="${app.path}/build.xml" target="build.module" inheritall="false" inheritrefs="false"/>
<ant antfile="${webcontainer.path}/build.xml" target="build.module" inheritall="false" inheritrefs="false"/>
<ant antfile="${demo.path}/build.xml" target="build.module" inheritall="false" inheritrefs="false"/>
</target>

<target name="test" description="Run all tests available for echolot">
<target name="test" depends="dependencies" description="Run all tests available for echolot">
<ant antfile="${app.path}/build.xml" target="test" inheritall="false" inheritrefs="false"/>
<ant antfile="${webcontainer.path}/build.xml" target="test" inheritall="false" inheritrefs="false"/>
<ant antfile="${demo.path}/build.xml" target="test" inheritall="false" inheritrefs="false"/>
</target>

<target name="run" description="Builds the Echolot demo application and runs it inline">
<target name="run" depends="dependencies" description="Builds the Echolot demo application and runs it inline">
<ant antfile="${demo.path}/build.xml" target="run" inheritall="false" inheritrefs="false" />
</target>

<target name="deploy" description="Deploys the demo instance of this application">
<target name="deploy" depends="dependencies" description="Deploys the demo instance of this application">
<ant antfile="echolot-demo/build.xml" target="war" inheritall="false" inheritrefs="false"/>
<ant antfile="echolot-demo/build.xml" target="remote.deploy" inheritall="false" inheritrefs="false"/>
</target>

<target name="dist" depends="clean" description="Generates a complete echolot distribution">
<target name="dist" depends="clean, dependencies" description="Generates a complete echolot distribution">

<echo>=== Building distributions of modules</echo>
<ant antfile="${app.path}/build.xml" target="dist" inheritall="false" inheritrefs="false"/>
Expand Down Expand Up @@ -206,4 +258,100 @@
<fileset dir="${dir.test.web}" includes="*.js"/>
</copy>
</target>

<!-- Maven deployment -->
<target name="-mvn.inittasks" unless="mvntasks.initialized">
<taskdef resource="de/exxcellent/ant/tasks.properties" classpath="resource/maven/ant-exxtasks-1.0.jar"/>
<extendclasspath path="resource/maven/maven-ant-tasks-2.1.3.jar"/>
<available property="mvntasks.initialized" classname="org.apache.maven.project.MavenProject"/>
</target>

<target name="-mvn.generate.pom">
<mkdir dir="${dir.build}/maven-pom"/>
<copy todir="${dir.build}/maven-pom" filtering="true" overwrite="true">
<fileset dir="resource/maven" includes="*.xml"/>
<filterset id="maven.pom.filters" begintoken="$${" endtoken="}">
<filter token="version" value="${release.version}"/>
<filter token="echo.version" value="${echo.version}"/>
</filterset>
</copy>
</target>

<target name="mvn.install" depends="dist, -mvn.generate.pom, -mvn.inittasks"
description="Installs the current release into the local maven repository">
<!-- Install Echo API module -->
<artifact:pom id="app-pom" file="${dir.build}/maven-pom/echolot-app-pom.xml" />
<artifact:install file="${dir.build.dist}/bin/echolot-app-${release.version}.jar">
<pom refid="app-pom"/>
<attach file="${dir.build.dist}/bin/echolot-app-${release.version}-sources.jar" type="jar" classifier="sources"/>
<attach file="${dir.build.dist}/bin/echolot-app-${release.version}-javadoc.jar" type="jar" classifier="javadoc"/>
</artifact:install>

<!-- Install Echo Web Servlet module -->
<artifact:pom id="webcontainer-pom" file="${dir.build}/maven-pom/echolot-webcontainer-pom.xml" />
<artifact:install file="${dir.build.dist}/bin/echolot-webcontainer-${release.version}.jar">
<pom refid="webcontainer-pom"/>
<attach file="${dir.build.dist}/bin/echolot-webcontainer-${release.version}-sources.jar" type="jar" classifier="sources"/>
<attach file="${dir.build.dist}/bin/echolot-webcontainer-${release.version}-javadoc.jar" type="jar" classifier="javadoc"/>
</artifact:install>
</target>

<target name="mvn.snapshot" depends="dist, -mvn.generate.pom, -mvn.inittasks"
description="Deploy snapshot version to configured Maven snapshot repository">
<!-- The artifact:deploy tasks do not repesct settings.xml for proxy/auth, so we use the mvn task -->
<!-- Deploy Echo App API module. -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
<arg value="-Durl=${maven.repository.snapshots.url}" />
<arg value="-DrepositoryId=${maven.repository.snapshots.id}" />
<arg value="-DpomFile=${dir.build}/maven-pom/echolot-app-pom.xml" />
<arg value="-Dfile=${dir.build.dist}/bin/echolot-app-${release.version}.jar" />
<arg value="-Dsources=${dir.build.dist}/bin/echolot-app-${release.version}-sources.jar" />
<arg value="-Djavadoc=${dir.build.dist}/bin/echolot-app-${release.version}-javadoc.jar" />
<arg value="-e" />
</artifact:mvn>

<!-- Deploy Echo Webcontainer API module. -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
<arg value="-Durl=${maven.repository.snapshots.url}" />
<arg value="-DrepositoryId=${maven.repository.snapshots.id}" />
<arg value="-DpomFile=${dir.build}/maven-pom/echolot-webcontainer-pom.xml" />
<arg value="-Dfile=${dir.build.dist}/bin/echolot-webcontainer-${release.version}.jar" />
<arg value="-Dsources=${dir.build.dist}/bin/echolot-webcontainer-${release.version}-sources.jar" />
<arg value="-Djavadoc=${dir.build.dist}/bin/echolot-webcontainer-${release.version}-javadoc.jar" />
<arg value="-e" />
</artifact:mvn>
</target>

<target name="mvn.stage" depends="dist, -mvn.generate.pom, -mvn.inittasks"
description="Deploy snapshot version to configured Maven snapshot repository">
<macrodef name="deploysigned">
<attribute name="module"/>
<attribute name="file"/>
<attribute name="classifier"/>

<sequential>
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${maven.repository.staging.url}" />
<arg value="-DrepositoryId=${maven.repository.staging.id}" />
<arg value="-DpomFile=${dir.build}/maven-pom/echolot-@{module}-pom.xml" />
<arg value="-Dfile=${dir.build.dist}/bin//@{file}" />
<arg value="-Dclassifier=@{classifier}" />
<arg value="-e" />
<arg value="-Pgpg" />
</artifact:mvn>
</sequential>
</macrodef>

<deploysigned module="app" classifier="" file="${dir.build.dist}/bin/echolot-app-${release.version}.jar"/>
<deploysigned module="app" classifier="sources" file="${dir.build.dist}/bin/echolot-app-${release.version}-sources.jar"/>
<deploysigned module="app" classifier="javadoc" file="${dir.build.dist}/bin/echolot-app-${release.version}-javadoc.jar"/>

<deploysigned module="webcontainer" classifier="" file="${dir.build.dist}/bin/echolot-webcontainer-${release.version}.jar"/>
<deploysigned module="webcontainer" classifier="sources" file="${dir.build.dist}/bin/echolot-webcontainer-${release.version}-sources.jar"/>
<deploysigned module="webcontainer" classifier="javadoc" file="${dir.build.dist}/bin/echolot-webcontainer-${release.version}-javadoc.jar"/>
</target>

</project>
8 changes: 4 additions & 4 deletions echolot-app/echolot-app.iml
Expand Up @@ -11,22 +11,22 @@
<orderEntry type="module-library" exported="">
<library name="echo3-app-3.0">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/echo3-app-3.0.jar!/" />
<root url="jar://$MODULE_DIR$/lib/echo3-app-3.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/lib/echo3-app-3.0-sources.jar!/" />
<root url="jar://$MODULE_DIR$/lib/echo3-app-3.0.0-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" exported="">
<library name="echo3-webcontainer-3.0">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/echo3-webcontainer-3.0.jar!/" />
<root url="jar://$MODULE_DIR$/lib/echo3-webcontainer-3.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/lib/echo3-webcontainer-3.0-sources.jar!/" />
<root url="jar://$MODULE_DIR$/lib/echo3-webcontainer-3.0.0-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
Expand Down
Binary file removed echolot-app/lib/compile/servlet-api-2.4.jar
Binary file not shown.
Binary file removed echolot-app/lib/echo3-app-3.0-sources.jar
Binary file not shown.
Binary file removed echolot-app/lib/echo3-app-3.0.jar
Binary file not shown.
Binary file removed echolot-app/lib/echo3-webcontainer-3.0-sources.jar
Binary file not shown.
Binary file removed echolot-app/lib/echo3-webcontainer-3.0.jar
Binary file not shown.
8 changes: 3 additions & 5 deletions echolot-webcontainer/echolot-webcontainer.iml
Expand Up @@ -13,7 +13,7 @@
<orderEntry type="module-library" scope="PROVIDED">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/compile/servlet-api-2.4.jar!/" />
<root url="jar://$MODULE_DIR$/lib/servlet-api-2.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
Expand All @@ -22,12 +22,10 @@
<orderEntry type="module-library" exported="" scope="RUNTIME">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/jdk15/stax-api-1.0-2.jar!/" />
<root url="jar://$MODULE_DIR$/lib/stax-api-1.0.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/lib/jdk15/stax-api-1.0-2-sources.jar!/src" />
</SOURCES>
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library" exported="">
Expand Down
Binary file removed echolot-webcontainer/lib/compile/servlet-api-2.4.jar
Binary file not shown.
2 changes: 0 additions & 2 deletions echolot-webcontainer/lib/jdk15/README.txt

This file was deleted.

Binary file not shown.
Binary file removed echolot-webcontainer/lib/jdk15/stax-api-1.0-2.jar
Binary file not shown.
Binary file removed echolot-webcontainer/lib/jettison-1.1-sources.jar
Binary file not shown.
Binary file removed echolot-webcontainer/lib/jettison-1.1.jar
Binary file not shown.
Binary file removed echolot-webcontainer/lib/test/jslint4java-1.4.2.jar
Binary file not shown.
Binary file removed echolot-webcontainer/lib/test/junit-4.5.jar
Binary file not shown.
Binary file removed echolot-webcontainer/lib/xstream-1.4.4-sources.jar
Binary file not shown.
Binary file removed echolot-webcontainer/lib/xstream-1.4.4.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions etc/build.properties
Expand Up @@ -4,6 +4,7 @@

# These settings are per module
release.version=1.0.1
echo.version=3.0.0

# Compile settings
build.jdk=1.5
Expand Down Expand Up @@ -37,3 +38,8 @@ deploy.ssh.username=echolot
deploy.ssh.password=boerg15
deploy.war.dir=target
deploy.webapp.name=echolot-demo

maven.repository.snapshots.id sonatype-nexus-snapshots
maven.repository.snapshots.url https://oss.sonatype.org/content/repositories/snapshots/
maven.repository.staging.id sonatype-nexus-staging
maven.repository.staging.url https://oss.sonatype.org/service/local/staging/deploy/maven2/
Binary file added resource/maven/ant-exxtasks-1.0-sources.jar
Binary file not shown.
Binary file added resource/maven/ant-exxtasks-1.0.jar
Binary file not shown.
44 changes: 44 additions & 0 deletions resource/maven/ant-exxtasks.txt
@@ -0,0 +1,44 @@

EXXCELLENT ANT TASKS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

EXTENDCLASSPATH

Mit diesem Task kann man den ClassPath von and selbst zur Laufzeit erweitern. Das ist an den Stellen notwendig und sinnvoll,
wo Ant selbst schon eine Task-Implementierung bereitstellt, aber noch weitere Abhängigkeiten im ANT_HOME/lib erwartet
(welche erst mal nicht vorhanden sind).

Beispiele hierfür sind die Ant Tasks <scp> und <ftp>.

Damit man also ein build-File ausliefern kann, welches diese Tasks verwendet aber NICHT VOM BENUTZER verlangt seine lokale
Ant-Installation anzupassen, braucht man den extendclasspath Tasks.

### Verwendungsbeispiel: ####

<target name="-init.ftptask" unless="ftptask.initialized">
<taskdef resource="de/exxcellent/ant/tasks.properties" classpath="tools/ant-colony/ant-clover/etc/ant-exxtasks.jar"/>
<extendclasspath path="${dir.tools}/ant-optional/commons-net-1.4.1.jar"/>
<extendclasspath path="${dir.tools}/ant-optional/jakarta-oro-2.0.8.jar"/>
<available property="ftptask.initialized" classname="org.apache.commons.net.ftp.FTPClientConfig"/>
</target>



LIZENZ

Diese Tasks stehen unter der MIT Lizenz

Copyright (c) 2011 eXXcellent solutions GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of
the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 comments on commit c3f97e8

Please sign in to comment.