I am migrating J2ee Project from Ant to Maven,
One of The ant tasks is to pull existing source from SVN Repository
Compile it, and add its jar to my current build as Jar
Is it possible to do the get the source and compile it in Maven?
Thank you!
<target name="checkoutBuild" description="Pulls code from SVN into the build directory">
<exec executable="svn">
<arg line="co ${svn.projecturl} ${project.build.root} -r ${svn.revision} --username ${svn.username} --password ${svn.password}"/>
</exec>
</target>
Yes, in a similar way as in Ant. Execute the svn
command in exec-maven-plugin
in one of pre-compile phases, perhaps in generate-sources. I'd try something like this (it's a brain-dump, may contain minor mistakes):
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>...</version>
<executions>
<execution>
<id>svn</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
<configuration>
<executable>svn</executable>
<arguments>
<argument>co</argument>
<argument>${svn.projecturl}</argument>
<argument>${project.build.root}</argument>
...
</arguments>
<configuration>
</plugin>
</plugins>
</build>
EDIT
Prunge's answer made me think — what do you want to really achieve? If the project is always to be the part of the build, a far better way would be to "mavenize" it (write a POM for it) and include it as a module/dependency.
If the SVN checkout is to be a one-time action, maybe it's better to leave it as it is, add the jar to the repository with mvn install:install-file
(assigning a group id and artifact id), and use it as a dependency?
You probably can, but it is not the 'Maven Way' of doing things.
Take a look at the Maven Release Plugin documentation.
What you'd typically do is:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With