Home » Java » Enterprise Java » Apache Ant 1.10.6 released – fork mode for junitlauncher and new jmod and link tasks

About Jaikiran Pai

Jaikiran Pai
Jaikiran works for Red Hat and is a developer in the JBoss application server development team. He's one of the authors of "JBoss AS Getting Started" DZone RefCard. When he's not doing anything JBoss related, you can usually find him at JavaRanch, in his role as a Sheriff(Moderator). He blogs at jaitechwriteups

Apache Ant 1.10.6 released – fork mode for junitlauncher and new jmod and link tasks

Apache Ant 1.10.6 has been released this week. This release contains numerous bug fixes as well as some very exciting new features. The complete release notes is available here and the downloads itself are available here. In this article, I will go over some of the new features that have made it into this release.

Running JUnit5 tests in a forked JVM, using junitlauncher task

A while back, Ant 1.10.x introduced support for JUnit5 tests to be launched using the new “junitlauncher” task. Given the nature of changes between JUnit 4.x and JUnit 5, the amount of support introduced in the new “junitlauncher” task was minimal. Based on user feedback about this task, this task has now been enhanced to support “fork” mode. This was one of the most asked for enhancement, in this task. The “fork” mode support in this task now allows users to configure this task to launch the tests in a forked JVM instead of running these tests within the same JVM as the one, the build is currently running in. Fork mode allows much more control over how these tests execute (things like setting up additional JVM arguments just for these tests or even system properties). The complete details of how to use fork mode in this task, is available in the manual for this task. Here’s a very basic minimal example of one such usage:

<target name="test-basic-fork">
        <junitlauncher>
         <!-- Imagine test.classpath points to a previously configured path -->
            <classpath refid="test.classpath"/>
            <test name="org.example.myapp.SampleTest" outputdir="${output.dir}">
                <fork dir="${basedir}">
                    <sysproperty key="myapp-system-property" value="hello world!"/>
                </fork>
            </test>
        </junitlauncher>
</target>

The example above, sets up “junitlauncher” task to launch a test class named “org.example.myapp.SampleTest” in a forked JVM. The “fork” element in the example above is configured to setup a Java system property named “myapp-system-property” with a value of “hello world!”. When the test executes, this Java system property will be made available to this test or any other class being executed in that forked JVM. More advanced ability of the “fork” element is explained in the manual linked previously.

New jmod and link tasks for Java 9+ tools

Java 9 shipped with a new modular ecosystem. This also brought in new tools to create and manage the Java modules. In this release of Ant 1.10.6, we introduce new tasks – “jmod” and “link”, which can be used to create Java modules and then assemble them to create custom JVM runtime images. More details about these tasks can be found in their manuals
here and here. A big thanks to Craig Pell who contributed these valuable tasks. More Java 9+ enhancements are being worked upon in Ant and we plan to make them available in future releases.

Please do download this new version of Ant and provide us feedback, suggestions in our user mailing list.

Published on Java Code Geeks with permission by Jaikiran Pai, partner at our JCG program. See the original article here: Apache Ant 1.10.6 released – fork mode for junitlauncher and new jmod and link tasks

Opinions expressed by Java Code Geeks contributors are their own.

(0 rating, 0 votes)
You need to be a registered member to rate this.
Start the discussion Views Tweet it!
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of