Skip to content

Gradle tasks known to work

Tomasz Jędrzejewski edited this page Mar 13, 2018 · 3 revisions

Module name

Starting from 0.2.1, Chainsaw automatically recognizes module-info.java descriptor and extracts the module name directly from it. There is no need to specify the module name manually in the build.gradle file.

If the project contains src/main/java directory, it is expected that it contains the Java module descriptor.

If there is no src/main/java directory, Chainsaw ignores such a project and does not apply any customizations. This means that you can safely apply this module for the root project in the multi-project setup.

Module name conventions

Modules are tightly related to packages. The official recommendation is to use reverse-DNS style, and name your module from the root package. By default, the plugin enforces this convention and checks whether there is a single, root package in /src/main/java corresponding to the module name.

If you are migrating an existing code to modules, and the module name cannot match the recommendation, you can disable the check:

javaModule.allowModuleNamingViolations = true

Remember that Java 9 does not allow package splits (using identical packages in multiple modules).

Unit tests

The plugin recognizes JUnit 4 and JUnit 5 dependencies and configures the test launcher accordingly. Unit tests are attached to the main code through the --patch-module flag, so they are considered by the JVM as a part of your module, and have the unrestricted access to the code being tested.

Both project and test resources are accessible inside unit tests.

Unit tests don't have their own module descriptor. To make additional test modules (such as Mockito) accessible, use javaModule.extraTestModules flag.

Incremental compilation

It is known to work (see: IncrementalCompilationSpec.groovy test case)

Javadocs

The plugin recognizes and reconfigures javadoc task. It is also known to work with Nebula Javadoc JAR plugin.

Run task

It is possible to run Jigsaw application, using run task.

Creating start scripts

As of 0.3.0, there is a number of issues related to the generated start scripts. They are going to be fixed in the upcoming releases.

Note that Java does not currently support building uber-JARs for modular application (JAR archive can contain at most one Jigsaw module). This is expected to change in the future Java versions.

Apt plugin and annotation processors

If you are using the annotation processing plugin net.ltgt.apt, the plugin must be applied AFTER Chainsaw!