Skip to content

Commit 6f214a1

Browse files
committed
Maven deployment update.
Analogous to the echo3filetransfer library, the ant build uses the Maven Ant Tasks to fetch required dependencies and to upload/stage a snapshot version to Maven Central.
1 parent 3fb9861 commit 6f214a1

8 files changed

Lines changed: 343 additions & 116 deletions

ant.properties

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
1-
release.version 3.0.b8
1+
release.version 3.0.0-SNAPSHOT
2+
echo.version 3.0.0
23

3-
ant.build.javac.source 1.4
4-
ant.build.javac.target 1.4
4+
ant.build.javac.source 1.4
5+
ant.build.javac.target 1.4
56

6-
servlet.lib.jar ${env.SERVLET_LIB_JAR}
7-
servlet.lib.msg The environment variable SERVLET_LIB_JAR must contain the path to the Servlet 2.4 \
7+
servlet.lib.jar lib/servlet-api-2.4.jar
8+
servlet.lib.msg The ant property servlet.lib.jar must contain the path to the Servlet 2.4 \
89
specification JAR file (servlet.jar or servlet-api.jar).
910

10-
echo3.app.lib.jar ${env.ECHO3_LIB_HOME}/Echo3_App.jar
11-
echo3.webcontainer.lib.jar ${env.ECHO3_LIB_HOME}/Echo3_WebContainer.jar
11+
echo3.app.lib.jar lib/echo3-app-${echo.version}.jar
12+
echo3.webcontainer.lib.jar lib/echo3-webcontainer-${echo.version}.jar
1213

1314
debug yes
1415
jarfile.extras.app echo3-extras-app-${release.version}.jar
1516
jarfile.extras.webcontainer echo3-extras-webcontainer-${release.version}.jar
1617
srcfile.extras.app echo3-extras-app-${release.version}-sources.jar
1718
srcfile.extras.webcontainer echo3-extras-webcontainer-${release.version}-sources.jar
19+
docfile.extras.app echo3-extras-app-${release.version}-javadoc.jar
20+
docfile.extras.webcontainer echo3-extras-webcontainer-${release.version}-javadoc.jar
1821
warfile.testapp ExtrasTest.war
19-
fileprefix.release echo3-extras
22+
fileprefix.release ${ant.project.name}
2023
zipfile.release ${fileprefix.release}-${release.version}.zip
2124
tarfile.release ${fileprefix.release}-${release.version}.tar
2225
tgzfile.release ${fileprefix.release}-${release.version}.tgz
2326

2427
dir.temp tmp
2528

2629
dir.src src
30+
dir.lib lib
31+
2732
dir.src.client ${dir.src}/client
2833
dir.src.client.extras ${dir.src.client}/extras
2934

@@ -58,7 +63,7 @@ dir.build.server-java.webcontainer ${dir.build.server-java}/webcontainer
5863
dir.build.server-java.webcontainer.res ${dir.build.server-java.webcontainer}/nextapp/echo/extras/webcontainer/resource
5964
dir.build.server-java.testapp ${dir.build.server-java}/testapp
6065
dir.build.server-java.release ${dir.build.server-java}/release
61-
dir.build.server-java.release.root ${dir.build.server-java.release}/NextApp_Echo3_Extras
66+
dir.build.server-java.release.root ${dir.build.server-java.release}/${ant.project.name}
6267

6368
dir.dist dist
6469
dir.dist.lib ${dir.dist}/lib
@@ -72,3 +77,8 @@ javadoc.doctitle.app Echo3 Extras <br>API Specification
7277
javadoc.doctitle.webcontainer Echo3 Extras Container<br>API Specification
7378
javadoc.header <b>NextApp Echo3 Extras<br>${javadoc.version}</b>
7479
javadoc.cssfile ${dir.resource}/javadoc.css
80+
81+
maven.repository.snapshots.id sonatype-nexus-snapshots
82+
maven.repository.snapshots.url https://oss.sonatype.org/content/repositories/snapshots/
83+
maven.repository.staging.id sonatype-nexus-staging
84+
maven.repository.staging.url https://oss.sonatype.org/service/local/staging/deploy/maven2/

build.xml

Lines changed: 135 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* the terms of any one of the MPL, the GPL or the LGPL.
3030
-->
3131

32-
<project name="echo3-extras" default="dist" basedir=".">
32+
<project name="echo3-extras" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
3333

3434
<property environment="env"/>
3535
<property file="custom-ant.properties"/>
@@ -46,9 +46,39 @@
4646
<include name="**/*stylesheet"/>
4747
</patternset>
4848

49+
<target name="-check.dependencies">
50+
<available file="${dir.lib}/echo3-app-${echo.version}.jar" property="dependencies.present"/>
51+
</target>
52+
53+
<target name="mvn.dependencies" depends="-mvn.inittasks"
54+
description="Fetches the required dependencies from Maven Central into the lib dir">
55+
56+
<artifact:dependencies filesetId="dependency.fileset">
57+
<dependency groupId="com.nextapp" artifactId="echo3-app" version="${echo.version}"/>
58+
<dependency groupId="com.nextapp" artifactId="echo3-app" version="${echo.version}" classifier="sources"/>
59+
<dependency groupId="com.nextapp" artifactId="echo3-webcontainer" version="${echo.version}"/>
60+
<dependency groupId="com.nextapp" artifactId="echo3-webcontainer" version="${echo.version}" classifier="sources"/>
61+
<dependency groupId="javax.servlet" artifactId="servlet-api" version="2.4"/>
62+
<dependency groupId="javax.servlet" artifactId="servlet-api" version="2.4" classifier="sources"/>
63+
<dependency groupId="junit" artifactId="junit" version="4.11" scope="test"/>
64+
<dependency groupId="junit" artifactId="junit" version="4.11" scope="test" classifier="sources"/>
65+
</artifact:dependencies>
66+
67+
<copy todir="${dir.lib}">
68+
<fileset refid="dependency.fileset" />
69+
<mapper type="flatten" />
70+
</copy>
71+
</target>
72+
73+
<target name="dependencies" depends="-check.dependencies" unless="dependencies.present"
74+
description="Spot checks for dependency JARs availability and fetches via Maven Central if required">
75+
<antcall target="mvn.dependencies"/>
76+
</target>
77+
4978
<!-- Minimize -->
5079
<target name="minimize" depends="clean" description="Removes all non-essential files, including Eclipse temporary/build output files">
5180
<delete dir="${dir.temp}"/>
81+
<delete dir="${dir.lib}"/>
5282
</target>
5383

5484
<!-- Clean -->
@@ -61,7 +91,7 @@
6191
<delete dir="${dir.release}"/>
6292
</target>
6393

64-
<target name="compile.app" description="Compile Application source files">
94+
<target name="compile.app" description="Compile Application source files" depends="dependencies">
6595
<mkdir dir="${dir.build.server-java.app}"/>
6696
<javac srcdir="${dir.src.server-java.app}" destdir="${dir.build.server-java.app}"
6797
debug="${debug}" deprecation="yes" source="${ant.build.javac.source}" target="${ant.build.javac.target}">
@@ -87,6 +117,7 @@
87117
<javac srcdir="${dir.src.server-java.app-test}" destdir="${dir.build.server-java.app-test}"
88118
debug="${debug}" deprecation="yes" source="${ant.build.javac.source}" target="${ant.build.javac.target}">
89119
<classpath>
120+
<pathelement path="${dir.dist.lib}/${jarfile.extras.app}"/>
90121
<pathelement path="${echo3.app.lib.jar}"/>
91122
<pathelement path="${dir.dist.lib}/${jarfile.echo.app}"/>
92123
</classpath>
@@ -103,6 +134,7 @@
103134
<junit printsummary="yes" haltonfailure="no">
104135
<classpath>
105136
<pathelement path="${echo3.app.lib.jar}"/>
137+
<pathelement path="${dir.build.server-java.app}"/>
106138
<pathelement path="${dir.build.server-java.app-test}"/>
107139
<pathelement path="${dir.dist.lib}/${jarfile.echo.app}"/>
108140
</classpath>
@@ -282,9 +314,14 @@
282314
<target name="doc.private"
283315
depends="doc.app.private, doc.webcontainer.private"/>
284316

285-
<target name="doc"
317+
<target name="doc.jars" depends="doc.public" description="Builds the *-javadoc.jar files">
318+
<jar jarfile="${dir.dist.lib}/${docfile.extras.app}" basedir="${dir.javadoc.app.public}"/>
319+
<jar jarfile="${dir.dist.lib}/${docfile.extras.webcontainer}" basedir="${dir.javadoc.webcontainer.public}"/>
320+
</target>
321+
322+
<target name="doc"
286323
depends="doc.app, doc.app.private, doc.webcontainer, doc.webcontainer.private"/>
287-
324+
288325
<target name="release" depends="clean, dist, dist.testapp, doc.public">
289326
<mkdir dir="${dir.build.server-java.release.root}"/>
290327
<mkdir dir="${dir.build.server-java.release.root}/SourceCode"/>
@@ -342,69 +379,97 @@
342379
<delete file="${dir.release}/${tarfile.release}"/>
343380
</target>
344381

345-
<target name="mvn-install" depends="dist" description="Installs the jar into the local maven repository">
346-
<condition property="onWindows">
347-
<os family="windows"/>
348-
</condition>
349-
<antcall target="mvn-install-win"/>
350-
<antcall target="mvn-install-unix"/>
351-
</target>
352-
353-
<target name="mvn-install-win"
354-
description="Installs the jars into the local maven repository (windows environment)"
355-
if="onWindows">
356-
<exec executable="cmd">
357-
<arg value="/c"/>
358-
<arg value="mvn install:install-file -DpomFile=resource/maven/echo3extras-app-pom.xml -Dfile=dist${file.separator}lib${file.separator}${jarfile.extras.app}"/>
359-
</exec>
360-
<exec executable="cmd">
361-
<arg value="/c"/>
362-
<arg value="mvn install:install-file -DpomFile=resource/maven/echo3-app-pom.xml -Dfile=dist${file.separator}lib${file.separator}${srcfile.extras.app} -Dclassifier=sources"/>
363-
</exec>
364-
<exec executable="cmd">
365-
<arg value="/c"/>
366-
<arg value="mvn install:install-file -DpomFile=resource/maven/echo3extras-webcontainer-pom.xml -Dfile=dist${file.separator}lib${file.separator}${jarfile.extras.webcontainer}"/>
367-
</exec>
368-
<exec executable="cmd">
369-
<arg value="/c"/>
370-
<arg value="mvn install:install-file -DpomFile=resource/maven/echo3-app-pom.xml -Dfile=dist${file.separator}lib${file.separator}${srcfile.extras.webcontainer} -Dclassifier=sources"/>
371-
</exec>
382+
<target name="-mvn.generate.pom">
383+
<mkdir dir="${dir.build}/maven-pom"/>
384+
<copy todir="${dir.build}/maven-pom" filtering="true" overwrite="true">
385+
<fileset dir="resource/maven" includes="*.xml"/>
386+
<filterset id="maven.pom.filters" begintoken="$${" endtoken="}">
387+
<filter token="release.version" value="${release.version}"/>
388+
<filter token="echo.version" value="${echo.version}"/>
389+
</filterset>
390+
</copy>
372391
</target>
373-
374-
<target name="mvn-install-unix"
375-
description="Installs the jar into the local maven repository (unix environment)"
376-
unless="onWindows">
377-
<exec executable="mvn">
378-
<arg value="install:install-file"/>
379-
<arg value="-DpomFile=resource/maven/echo3extras-app-pom.xml"/>
380-
<arg value="-Dfile=dist${file.separator}lib${file.separator}${jarfile.extras.app}"/>
381-
</exec>
382-
<exec executable="mvn">
383-
<arg value="install:install-file"/>
384-
<arg value="-DpomFile=resource/maven/echo3extras-app-pom.xml"/>
385-
<arg value="-Dclassifier=sources"/>
386-
<arg value="-Dfile=dist${file.separator}lib${file.separator}${srcfile.extras.app}"/>
387-
</exec>
388-
<exec executable="mvn">
389-
<arg value="install:install-file"/>
390-
<arg value="-DpomFile=resource/maven/echo3extras-webcontainer-pom.xml"/>
391-
<arg value="-Dfile=dist${file.separator}lib${file.separator}${jarfile.extras.webcontainer}"/>
392-
</exec>
393-
<exec executable="mvn">
394-
<arg value="install:install-file"/>
395-
<arg value="-DpomFile=resource/maven/echo3extras-webcontainer-pom.xml"/>
396-
<arg value="-Dclassifier=sources"/>
397-
<arg value="-Dfile=dist${file.separator}lib${file.separator}${srcfile.extras.webcontainer}"/>
398-
</exec>
392+
393+
<target name="mvn.install" depends="dist, doc.jars, -mvn.generate.pom, -mvn.inittasks"
394+
description="Installs the current release into the local maven repository">
395+
<!-- Install Extras API module -->
396+
<artifact:pom id="app-pom" file="${dir.build}/maven-pom/echo3extras-app-pom.xml" />
397+
<artifact:install file="${dir.dist.lib}/${jarfile.extras.app}">
398+
<pom refid="app-pom"/>
399+
<attach file="${dir.dist.lib}/${srcfile.extras.app}" type="jar" classifier="sources"/>
400+
<attach file="${dir.dist.lib}/${docfile.extras.app}" type="jar" classifier="javadoc"/>
401+
</artifact:install>
402+
403+
<!-- Install Extras Web Servlet module -->
404+
<artifact:pom id="webcontainer-pom" file="${dir.build}/maven-pom/echo3extras-webcontainer-pom.xml" />
405+
<artifact:install file="${dir.dist.lib}/${jarfile.extras.webcontainer}">
406+
<pom refid="webcontainer-pom"/>
407+
<attach file="${dir.dist.lib}/${srcfile.extras.webcontainer}" type="jar" classifier="sources"/>
408+
<attach file="${dir.dist.lib}/${docfile.extras.webcontainer}" type="jar" classifier="javadoc"/>
409+
</artifact:install>
399410
</target>
400-
401-
<target name="jslint.extras">
402-
<java fork="true" jar="${dir.resource.jslint}/rhino.jar">
403-
<arg value="${dir.resource.jslint}/jslint.js"/>
404-
<arg value="${dir.src.client.extras}/"/>
405-
</java>
411+
412+
<target name="mvn.snapshot" depends="dist, doc.jars, -mvn.generate.pom, -mvn.inittasks"
413+
description="Deploy snapshot version to configured Maven snapshot repository">
414+
<!-- The artifact:deploy tasks do not repesct settings.xml for proxy/auth, so we use the mvn task -->
415+
<!-- Deploy Echo API module. -->
416+
<artifact:mvn>
417+
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
418+
<arg value="-Durl=${maven.repository.snapshots.url}" />
419+
<arg value="-DrepositoryId=${maven.repository.snapshots.id}" />
420+
<arg value="-DpomFile=${dir.build}/maven-pom/echo3extras-app-pom.xml" />
421+
<arg value="-Dfile=${dir.dist.lib}/${jarfile.extras.app}" />
422+
<arg value="-Dsources=${dir.dist.lib}/${srcfile.extras.app}" />
423+
<arg value="-Djavadoc=${dir.dist.lib}/${docfile.extras.app}" />
424+
<arg value="-e" />
425+
</artifact:mvn>
426+
<artifact:mvn>
427+
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
428+
<arg value="-Durl=${maven.repository.snapshots.url}" />
429+
<arg value="-DrepositoryId=${maven.repository.snapshots.id}" />
430+
<arg value="-DpomFile=${dir.build}/maven-pom/echo3extras-webcontainer-pom.xml" />
431+
<arg value="-Dfile=${dir.dist.lib}/${jarfile.extras.webcontainer}" />
432+
<arg value="-Dsources=${dir.dist.lib}/${srcfile.extras.webcontainer}" />
433+
<arg value="-Djavadoc=${dir.dist.lib}/${docfile.extras.webcontainer}" />
434+
<arg value="-e" />
435+
</artifact:mvn>
436+
</target>
437+
438+
<target name="mvn.stage" depends="dist, doc.jars, -mvn.generate.pom, -mvn.inittasks"
439+
description="Deploy snapshot version to configured Maven snapshot repository">
440+
<macrodef name="deploysigned">
441+
<attribute name="module"/>
442+
<attribute name="file"/>
443+
<attribute name="classifier"/>
444+
445+
<sequential>
446+
<artifact:mvn>
447+
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
448+
<arg value="-Durl=${maven.repository.staging.url}" />
449+
<arg value="-DrepositoryId=${maven.repository.staging.id}" />
450+
<arg value="-DpomFile=${dir.build}/maven-pom/echo3extras-@{module}-pom.xml" />
451+
<arg value="-Dfile=${dir.dist.lib}/@{file}" />
452+
<arg value="-Dclassifier=@{classifier}" />
453+
<arg value="-e" />
454+
<arg value="-Pgpg" />
455+
</artifact:mvn>
456+
</sequential>
457+
</macrodef>
458+
459+
<deploysigned module="app" classifier="" file="${jarfile.extras.app}"/>
460+
<deploysigned module="app" classifier="sources" file="${srcfile.extras.app}"/>
461+
<deploysigned module="app" classifier="javadoc" file="${docfile.extras.app}"/>
462+
463+
<deploysigned module="webcontainer" classifier="" file="${jarfile.extras.webcontainer}"/>
464+
<deploysigned module="webcontainer" classifier="sources" file="${srcfile.extras.webcontainer}"/>
465+
<deploysigned module="webcontainer" classifier="javadoc" file="${docfile.extras.webcontainer}"/>
406466
</target>
407467

468+
<target name="-mvn.inittasks" unless="mvntasks.initialized">
469+
<taskdef resource="de/exxcellent/ant/tasks.properties" classpath="resource/maven/ant-exxtasks-1.0.jar"/>
470+
<extendclasspath path="resource/maven/maven-ant-tasks-2.1.3.jar"/>
471+
<available property="mvntasks.initialized" classname="org.apache.maven.project.MavenProject"/>
472+
</target>
408473

409474
<target name="jslint.webcontainer">
410475
<java fork="true" jar="${dir.resource.jslint}/rhino.jar">
@@ -413,6 +478,13 @@
413478
</java>
414479
</target>
415480

481+
<target name="jslint.extras">
482+
<java fork="true" jar="${dir.resource.jslint}/rhino.jar">
483+
<arg value="${dir.resource.jslint}/jslint.js"/>
484+
<arg value="${dir.src.client.extras}/"/>
485+
</java>
486+
</target>
487+
416488
<target name="jslint" depends="jslint.extras,jslint.webcontainer">
417489
</target>
418490

2.86 KB
Binary file not shown.
2.87 KB
Binary file not shown.

resource/maven/ant-exxtasks.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
EXXCELLENT ANT TASKS
3+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4+
5+
EXTENDCLASSPATH
6+
7+
Mit diesem Task kann man den ClassPath von and selbst zur Laufzeit erweitern. Das ist an den Stellen notwendig und sinnvoll,
8+
wo Ant selbst schon eine Task-Implementierung bereitstellt, aber noch weitere Abhängigkeiten im ANT_HOME/lib erwartet
9+
(welche erst mal nicht vorhanden sind).
10+
11+
Beispiele hierfür sind die Ant Tasks <scp> und <ftp>.
12+
13+
Damit man also ein build-File ausliefern kann, welches diese Tasks verwendet aber NICHT VOM BENUTZER verlangt seine lokale
14+
Ant-Installation anzupassen, braucht man den extendclasspath Tasks.
15+
16+
### Verwendungsbeispiel: ####
17+
18+
<target name="-init.ftptask" unless="ftptask.initialized">
19+
<taskdef resource="de/exxcellent/ant/tasks.properties" classpath="tools/ant-colony/ant-clover/etc/ant-exxtasks.jar"/>
20+
<extendclasspath path="${dir.tools}/ant-optional/commons-net-1.4.1.jar"/>
21+
<extendclasspath path="${dir.tools}/ant-optional/jakarta-oro-2.0.8.jar"/>
22+
<available property="ftptask.initialized" classname="org.apache.commons.net.ftp.FTPClientConfig"/>
23+
</target>
24+
25+
26+
27+
LIZENZ
28+
29+
Diese Tasks stehen unter der MIT Lizenz
30+
31+
Copyright (c) 2011 eXXcellent solutions GmbH
32+
33+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
34+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
35+
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
36+
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
37+
38+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of
39+
the Software.
40+
41+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
42+
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
43+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
44+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)