You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by martin_CY <ma...@hotmail.com> on 2007/07/20 13:53:16 UTC

Re: migrating to Maven2, but some issues.

Hi everyone, this is for those that might be struggling with a similar
situation.

I did come up with a solution, though don't know if its the best, but for
now it works for us.

and to me the the solution is called maven-ant-tasks!

we decided that for now we will only use maven for handling external jars
(for which maven is very good) and continue to build with ant our multiple
jars and then over time we will try to slowly break out modules that only
have one way dependencies.

In the end this first move was not all that bad for us.

to give you some examples what i did with our build.xml

added:

<target name="initTaskDefs">
		<path id="maven.classpath">
			<pathelement location="lib/maven-ant-tasks-2.0.7.jar" />
		</path>

		<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant">
			<classpath refid="maven.classpath" />
		</typedef>
		<artifact:pom file="pom.xml" id="maven.project" />
		<artifact:remoteRepository id="deploy.repository"
url="scp://maven.intern.albourne.com/secure/maven" />
	</target>

which basically sources in the maven-ant.task-2.0.7.jar and make all the
maven stuff available from ant! and most important the <artifact:pom
file="pom.xml" id="maven.project" /> which source in your main POM that has
all your dependencies as well as your repository links etc.

then I copy out all the external jars from my dependencies to a nice
location to be used with the deployment:
<target name="copyLibs" depends="initTaskDefs">
		<!--copy the external jars to target/lib from maven repository into a flat
un-versioned structure-->
		<artifact:dependencies filesetId="my.compile.dependency.fileset"
versionsId="lates.version.to.use" useScope="compile">
			<pom refid="maven.project" />
		</artifact:dependencies>
		<copy todir="target/lib">
			<fileset refid="my.compile.dependency.fileset" />
			<mapper classpathref="maven.classpath"
classname="org.apache.maven.artifact.ant.VersionMapper"
from="${lates.version.to.use}" to="flatten" />
		</copy>
		<!-- Definition of all the libraries -->
		<fileset dir="target/lib" id="libraries">
			<include name="*.jar" />
		</fileset>
	</target>


then of course use these libraries when you compile, and then generate your
multiple jars as before with ant.

I took it one step further as well, as i wanted all of our company jars to
be available on our internal maven repository 

so first i created another ant target that generates pom.xml files on the
fly (calling a shell script to generate it) for the separate jars that ant
builds (based on version properties in ant script)

then i deploy the  with a new target:
<target name="deploy" depends="initTaskDefs,generatePoms,export">
		<!--deploy jars to the maven repository using scp and the repositary
setting 
		that are defined the scripts/generatePom.sh and username/password as
defined in 
		the settings.xml -->
		<artifact:install-provider artifactId="wagon-ssh" version="1.0-alpha-7" />
		<artifact:deploy file="${software}/jar1.jar">
			<pom file="target/jar1.pom" />
		</artifact:deploy>
		<artifact:deploy file="${software}/jar2.jar">
			<pom file="target/jar2.pom" />
		</artifact:deploy>
</target>

and that will deploy my jars to the repository! 

and thats basically how we are handling it now. We have started to break out
code into their own modules but we dont expect to be fully broken out for
another 12-18 months and until then I will keep modifying the ant script to
continue to build this way, and eventually we will only use Maven to deploy
and ant will be a thing of the past.

but it is possible to use Maven for unit test purposes as well! which we are
doing currently to run our tests nightly, since tests run before building
jars I've setup in the main POM to basically include EVERYTHING and have a
single jar output (but i never build the jar) and that way i can run all
tests on a nightly basis, and if that works correctly i call the ant script
to build and deploy the jars both to be used for webstart and to the
internal repository to be used in other projects as dependencies.



good luck!
-- 
View this message in context: http://www.nabble.com/migrating-to-Maven2%2C-but-some-issues.-tf3994413s177.html#a11706792
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org