Is there an ivy/ant equivalent to mvn jar-with-dependencies? - ant

With maven-assembly-plugin it's possible to package a project into a single jar w all the dependencies.

I have not used it by myself, but one-jar seems to do what you need. It also has an ant task and offers an ant example.

Related

Is there a way to let gradle use a specific ant version?

I am working with a third party framework that I am integrating gradle into. I am calling some old ant tasks. The problem is that the third party framework wants me to use:
either its own ant, that is packaged with it
a specific ant version, in this case 1.9.1
Unfortunately there is no way to set the ant version that is used by gradle. I can not figure out if its is possible to point gradle to any specific version within my environment.
So what do you think I could do?
Thanks in advance,
Denis.
If you need to use a different Ant version than the one that comes with Gradle, you'll have to call out to Ant via a JavaExec or Exec task, rather than using Gradle's built-in Ant support.

Gradle Ant Cannot add task ':myproject:test' as a task with that name already exists

I'm trying to Gradle-ize our build by using Gradle to execute the Ant build. I'm using the java plugin so I can set source/target and I'm using ant.importBuild 'build.xml'. When I execute Gradle, I get the error above. I understand that both Ant and Gradle have these targets/tasks in common: clean, jar, javadoc, test. One option is to change the Ant target names in build.xml, but I'm hoping there's an easier way as I have a lot of projects and build files. I found this "wrapper" solution (http://issues.gradle.org/browse/GRADLE-771), but this did not work for me. How can I solve this?
Your options are:
Do not apply the plugin to the same project that imports the Ant build.
Rename the conflicting targets in the Ant build script.
You can rename all the ant targets:
ant.importBuild('build.xml') { String oldTargetName ->
return 'ant_' + oldTargetName
}

Can we use pom.xml into ANT

I know that, we can very well use ANT and Maven together to build the project.We can run ANT scripts through Maven's POM.xml. But my question is can we run pom.xml through ANT's build.xml ?
i.e. can we create maven build from build.xml
Yes, using maven ant tasks.
The page lists out multiple maven tasks which can be integrated into an ant build script, thus combining the features of both. To take an example, there is the mvn task, which as documented can do a full maven build from ant.
<artifact:mvn mavenHome="/path/to/maven-3.0.x">
<arg value="install"/>
</artifact:mvn>
Besides this, there are
Dependencies task
Install and Deploy tasks
Pom task
each described with examples.
Maven and ANT are very different build tools. In ANT you write all the logic yourself, whereas a standard build process is "baked in" with Maven.
The POM file contains no logic, instead it contains a series of declarations about your project.
If you understand well how Maven works, it is theoretically possible to take a POM and generate an ANT build that emulates the behaviour of the Maven build. I'm not aware of any solution which can easily convert in the other direction, mainly because ANT is missing Maven functionality, such as dependency management.
Instead of trying to convert an ANT build into Maven, I'd recommend that you keep your existing build logic and delegate the management of your classpath to the ivy or Maven ANT tasks. These tools also provide tasks to publish your build output to a Maven repository, enabling your project to share with other projects using Maven.
Finally, I'm an ivy advocate and wrote an ant2ivy script which can assist in upgrade process. It creates an initial set of configuration files for downloading your projects dependencies from the Maven central repository.

How can I build Maven dependencies from Ant Java classpath?

Using Maven Ant Tasks, I see lots of examples that build Ant classpath from Maven dependencies, but what about the other way round?
I have a carefully tuned Ant project that builds the Java task classpath from all the jars in my lib directory. How can I use Maven-Ant-tasks to use my classpath to build Maven dependencies?
I would rather not do each jar file individually (my last resort).
Is there a better way?
If you're working on converting from Ant to Maven, just bite the bullet and write out your <dependencies> section to match your ant classpath. You only have to do it once, and you'll thank yourself many times over.

How do you integrate ivy with MSbuild

What approach has worked well for you combining IVY + msbuild?
Our goal is to integrate IVY into the C#/C++ build process for dependency resolution and publishing. We have tried adding it to custom tasks at the beginning and end of the build and we have tried wrapping the msbuild calls with ant+ apache-ant-dotnet.
Other options might be gradle, buildr, rake.
What do you use?
Thanks
Peter
Most build technologies can use libraries found in a local directory. I'd suggest using the command-line ivy program to populate this, at the start of your build:
java -jar ivy.jar -ivy ivy.xml -settings ivysettings.xml -retrieve "lib/[conf]/[artifact].[ext]"
Your dependencies are listed in a standard ivy file called ivy.xml. The protocol, location and layout of your remote repository is described in ivysettings.xml
The advantage of this approach (as opposed to switching to Gradle, etc) is that you're not trying to replace your existing build tool. Ivy is solely concerned with managing dependencies.
My team has been using Ivy for .NET for a couple of years very successfully. I know several more that give it a vote of confidence.
Use it standalone. Wrap calls into msbuild tasks. No need to use Ant integration.

Resources