gradle-modules-plugin | Gradle plugin helps working with the Java Platform Module | Plugin library
kandi X-RAY | gradle-modules-plugin Summary
kandi X-RAY | gradle-modules-plugin Summary
This Gradle plugin helps working with the Java Platform Module System. The plugin is published in the [Gradle plugin repository] It makes building, testing and running modules seamless from the Gradle perspective. It sets up compiler and jvm settings with flags such as --module-path, so that you can build, test and run JPMS modules without manually setting up your build files. Also, you should disable the modularity.inferModulePath option introduced in Gradle 6.4: modularity.inferModulePath.set(false).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Configure module
- Configure start scripts
- Add javadoc options to module options
- Configure the compiler
- Configure the modules for compile
- Creates a copy of a patch module container
- Configure the given JavaCompile task
- Creates the compiler arguments
- Configure the compilation modules
- Pre - configure the compilation
- Configure the patch module
- Adjust the main class of the module
- Add a grand - child attribute
- Configure the run
- Sets the mixed Java release options
- Configure the Java release to use
- Adds the javadoc option to the options of the core
- Resolve a path to a module name
- Returns the gradle scope of an item
- Configures the Eclipse
- Configures merge classes after evaluator
- Moves all patched libraries to the location
gradle-modules-plugin Key Features
gradle-modules-plugin Examples and Code Snippets
Community Discussions
Trending Discussions on gradle-modules-plugin
QUESTION
I'm trying to create Java application using Java module system with gradle. I use this plugin: https://github.com/java9-modularity/gradle-modules-plugin as recommended by gradle. Java sources compile properly and use module-info.java as expected. However, my unit test does not work anymore. I want to use assertJ which is causing problems now. When I try to compile test classes, I'm getting this error:
error: package org.assertj.core.api is not visible import static org.assertj.core.api.Assertions.assertThat; ^ (package org.assertj.core.api is declared in module org.assertj.core, but module module.test.main does not read it)
I tried to set
...ANSWER
Answered 2020-Apr-28 at 15:36As documented in the plugin documentation, by default testing happens on the module path.
What you changed is about running tests. However test compilation also happens on the module path, you thus need the test dependencies to be properly imported by your module. Which is what the error is telling you.
As an alternative, you could try the native support in upcoming Gradle 6.4, a release candidate is available
QUESTION
I'm using Gradle (6.0.1) with the moduleplugin to build an application out of JPMS modules using JDK 13.
However, even with the application
plugin applied & its mainClassName
set it does not set the ModuleMainClass
attribute in module-info.class
, so when I jlink it up into a standalone JVM and run java -m mymodule
I get this message:
module mymodule does not have a ModuleMainClass attribute, use -m /
Digging under the hood it looks like the moduleplugin doesn't change the jar task at all, and the out of the box gradle jar task does not actually use the JDK's jar
command, it just zips everything up itself.
As far as I can tell the only way to set the ModuleMainClass
attribute in module-info.class
is to use the JDK's jar command as so: jar --main-class=CLASSNAME -C
.
Is there a way to do this, short of writing my own gradle task? And if not, has anyone got an example of replacing the gradle jar task with one that calls the JDK command?
(Please note this question is not about setting the Main-Class
in the jar's MANIFEST.MF - that's easy, but isn't respected when calling java -m
.)
ANSWER
Answered 2019-Dec-02 at 16:10It looks like the jar
task in gradle does not do a proper job of building the jar to also include the module-main-class
in the module-info.class
. In fact it doesn't look like it calls the jar
command at all which is a bit misleading. So here is an updated version that does this:
QUESTION
I'm working on a Java library targeting JDK 8, and I'm building it in Gradle 5 using OpenJDK 11. In order to target JDK 8, I'm javac's --release
option.
However, I'd also like my library to be JPMS-compatible. In other words:
- I'd like to provide a
module-info.class
compiled with--release 9
(option 3 in Stephen Colebourne's scale), - while all the rest is compiled with
--release 8
.
build.gradle:
...ANSWER
Answered 2019-Apr-07 at 18:02EDIT: This functionality is now supported by Gradle Modules Plugin since version 1.5.0.
Here's a working build.gradle
snippet:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gradle-modules-plugin
You can use gradle-modules-plugin like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the gradle-modules-plugin component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page