Ant use Maven's library - java

I wrote a project which use maven. It's good for me.
But, some other people don't have maven, so I am trying to write an ant build.xml for them.
My question is:
Inside "javac" -> "classpath" tag, how could ant get the libs I used in the project from maven? So that could compile & pack all the 3rd-party libs into release via ant.
Is this possible or there are better solution for maven & ant exists in same project.

Ant combined with Ivy is your answer. Ant can use a Maven repository to pull in jars, and can even be made to output a pom.xml, so the jar can be deployed back to a Maven repository.
I have an ivy.dir project on Github that I use to help integrate Ivy into already existing Ant tasks -- especially if they use Subversion as a version control system. You can create a ivy.dir subproject, and make that an external on the Ant project.

Have a look at ivy. Use it to download your dependencies for ant from a maven repository.

Related

Include external jars in ant

I am new to writing build files and currently I am writing the ant for my project. The issue I am facing is to include the jar to in ant build file.
As per the standard 'ant build' the jars need to be kept in lib folder. But the issue is the jar is very huge, more than 100 GB of size and hence cannot be kept in GitHub.
I have put that in another repository and want to include that in my build file.
Could anyone please let me know how to include the jars in my 'pathelement location' from the url.
Apache ivy is a 3rd party dependency manager, a powerful feature built into more modern Java build tools like Maven and Gradle.
The following answer gives a detailed example, using ivy to manage classpaths and help in the creation of an executable jar.
Class not found with Ant, Ivy and JUnit - error in build.xml?
You mentioned the use of another repository. Presumably this is a Maven repository manager like Nexus or Artifactory. Ivy is capable of downloading from these. (which would be another question :-))

Import jar from ant ivy project to maven

I am working on an ant project and i want to use the jar created by it , in my maven project.
The ant project employs ivy to manage its dependency.
Is there any easy way to do this if possible without changing any code on their side.
It sounds like you want to be able to publish artefacts generated by your ivy-based project to a maven repo so they can be resolved by the mvn-based project.
Try http://draconianoverlord.com/2010/07/18/publishing-to-maven-repos-with-ivy.html
Once the ivy-based project has published its artefacts to the mvn repo, then the mvn-based project should be able to resolve the published artefacts.

Use Maven to customize and build another Maven project

What I want to achieve is the following:
Checkout external project from svn
Replace spring.xml with my customized version
Change version of a dependency
Build
Package
Are there standard maven plugins to handle all these goals?
For svn operations, you can use: org.tmatesoft.svnkit:svnkit
For replacing spring.xml with a customized version: maven-assembly-plugin, maven-resources-plugin would both work, depending on what exactly you need to do (I'm assuming there's more work here).
For building and packaging, you can use the maven-invoker-plugin. That plugin basically lets you point at a project and run "mvn clean package" or whatever other maven commands you want such as invoking a plugin. It's pretty much just a way to run maven from maven.

Use maven + yguard

Has anybody used maven and yguard for obfuscating jar files?How to do so?
I have done obfuscation using yguard in Maven. I have used the maven ant run plugin to run the ant tasks.
Steps:
Refer to the build.xml in your pom.xml. Check documentation of Maven Antrun plugin. You have a lot of examples there.
Create the build.xml with the rename elements as required by your project/jar. In case you want to refer to the Maven references like project information, define them as properties in your pom.xml before the ant task is executed
Please let me know if this answers your question

Eclipse: Dependency Management

What are some methods of utilising Eclipse for Dependency Management?
I really like the The Maven Integration for Eclipse (m2eclipse, Eclipse m2e). I use it purely for the dependency management feature. It's great not having to go out and download a bunch of new jars new each time I set up a project.
A simpler way to go is the Maven Eclipse plugin (as opposed to a Maven plugin for Eclipse). It's simply a maven plugin that generates the .project and .classpath file based on the contents of the pom, you just run mvn eclipse:eclipse and you're done. It uses a classpath variable in Eclipse to locate the local maven repo.
I personally prefer this approach most of the time because you have more control over when the maven plugin updates are done. It's also one less Eclipse plugin to deal with. The GUI features of the m2eclipse plugin in the latest version is pretty nice, though.
There's also an alternative to the m2eclipse plugin called Q4E, now called Eclipse IAM.
Another option is ivy. Ivy has eclipse integration as well.
A comparison of maven and ivy can be found here:
http://ant.apache.org/ivy/m2comparison.html

Categories

Resources