-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
448 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
# Gradle Plugin: Java Module Dependencies | ||
# Java Module Dependencies Gradle plugin | ||
|
||
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fgradlex-org%2Fjava-module-dependencies%2Fbadge%3Fref%3Dmain&style=flat)](https://actions-badge.atrox.dev/gradlex-org/java-module-dependencies/goto?ref=main) | ||
[![Gradle Plugin Portal](https://img.shields.io/maven-metadata/v?label=Plugin%20Portal&metadataUrl=https%3A%2F%2Fplugins.gradle.org%2Fm2%2Forg%2Fgradlex%2Fjava-module-dependencies%2Forg.gradlex.java-module-dependencies.gradle.plugin%2Fmaven-metadata.xml)](https://plugins.gradle.org/plugin/org.gradlex.java-module-dependencies) | ||
|
||
A Gradle 7.4+ plugin to make Gradle use dependencies from _module-info.java_ files automatically. | ||
If you have a project that fully uses Java Modules, you do **not** need to declare dependencies in the `dependencies { }` block anymore | ||
|
@@ -13,26 +16,26 @@ as well as [Version Catalogs](https://docs.gradle.org/current/userguide/platform | |
Here is an overview of what the plugin does in a Twitter thread: | ||
[<img src="https://onepiecesoftware.github.io/img/tweets/1524322184923164672.png">](https://twitter.com/jeoj/status/1524322184923164672) | ||
|
||
This plugin is maintained by me, [Jendrik Johannes](https://github.com/jjohannes). | ||
This [GradleX](https://gradlex.org) plugin is maintained by me, [Jendrik Johannes](https://github.com/jjohannes). | ||
I offer consulting and training for Gradle and/or the Java Module System - please [reach out](mailto:[email protected]) if you are interested. | ||
There is also my [YouTube channel](https://www.youtube.com/playlist?list=PLWQK2ZdV4Yl2k2OmC_gsjDpdIBTN0qqkE) on Gradle topics. | ||
|
||
If you have a suggestion or a question, please [open an issue](https://github.com/jjohannes/java-module-dependencies/issues/new). | ||
If you have a suggestion or a question, please [open an issue](https://github.com/gradlex-org/java-module-dependencies/issues/new). | ||
|
||
There is a [CHANGELOG.md](CHANGELOG.md). | ||
|
||
# Java Modules with Gradle | ||
|
||
If you plan to build Java Modules with Gradle, you should consider using these plugins on top of Gradle core: | ||
|
||
- [`id("de.jjohannes.java-module-dependencies")`](https://github.com/jjohannes/java-module-dependencies) | ||
- [`id("org.gradlex.java-module-dependencies")`](https://github.com/gradlex-org/java-module-dependencies) | ||
Avoid duplicated dependency definitions and get your Module Path under control | ||
- [`id("de.jjohannes.java-module-testing")`](https://github.com/jjohannes/java-module-testing) | ||
- [`id("org.gradlex.java-module-testing")`](https://github.com/gradlex-org/java-module-testing) | ||
Proper test setup for Java Modules | ||
- [`id("de.jjohannes.extra-java-module-info")`](https://github.com/jjohannes/extra-java-module-info) | ||
- [`id("org.gradlex.extra-java-module-info")`](https://github.com/gradlex-org/extra-java-module-info) | ||
Only if your (existing) project cannot avoid using non-module legacy Jars | ||
|
||
[Here is a sample](https://github.com/jjohannes/java-module-testing/tree/main/samples/use-all-java-module-plugins) | ||
[Here is a sample](https://github.com/gradlex-org/java-module-testing/tree/main/samples/use-all-java-module-plugins) | ||
that shows all plugins in combination. | ||
|
||
[Full Java Module System Project Setup](https://github.com/jjohannes/gradle-project-setup-howto/tree/java_module_system) is a full-fledged Java Module System project setup using these plugins. | ||
|
@@ -51,11 +54,11 @@ you can check out my [Understanding Gradle video series](https://www.youtube.com | |
## Plugin dependency | ||
|
||
Add this to the build file of your convention plugin's build | ||
(e.g. `build-logic/build.gradle(.kts)` or `buildSrc/build.gradle(.kts)`). | ||
(e.g. `gradle/plugins/build.gradle(.kts)` or `buildSrc/build.gradle(.kts)`). | ||
|
||
``` | ||
dependencies { | ||
implementation("de.jjohannes.gradle:java-module-dependencies:0.11") | ||
implementation("org.gradlex:java-module-dependencies:1.0") | ||
} | ||
``` | ||
|
||
|
@@ -66,7 +69,7 @@ In your convention plugin, apply the plugin. | |
``` | ||
plugins { | ||
... | ||
id("de.jjohannes.java-module-dependencies") | ||
id("org.gradlex.java-module-dependencies") | ||
} | ||
``` | ||
|
||
|
@@ -76,8 +79,8 @@ You may define additional mappings from _Module Name_ to _group:name (GA) coordi | |
|
||
The plugin already knows about Modules available on Maven Central. The information is stored in: | ||
|
||
- [modules.properties](src/main/resources/de/jjohannes/gradle/moduledependencies/modules.properties) - [please open a PR](https://github.com/jjohannes/extra-java-module-info/pulls) if you miss an entry | ||
- [unique_modules.properties](src/main/resources/de/jjohannes/gradle/moduledependencies/unique_modules.properties) - this information is extracted from [modules.properties](https://github.com/sormuras/modules/blob/main/com.github.sormuras.modules/com/github/sormuras/modules/modules.properties) by [@sormuras](https://github.com/sormuras) | ||
- [modules.properties](src/main/resources/org/gradlex/javamodule/dependencies/modules.properties) - [please open a PR](https://github.com/gradlex-org/extra-java-module-info/pulls) if you miss an entry | ||
- [unique_modules.properties](src/main/resources/org/gradlex/javamodule/dependencies/unique_modules.properties) - this information is extracted from [modules.properties](https://github.com/sormuras/modules/blob/main/com.github.sormuras.modules/com/github/sormuras/modules/modules.properties) by [@sormuras](https://github.com/sormuras) | ||
|
||
You can define additional entries (or overwrite entries from the plugin) as follows: | ||
|
||
|
@@ -116,7 +119,7 @@ For libraries that consist of multiple components and have a BOM for version man | |
``` | ||
plugins { | ||
id("java-platform") | ||
id("de.jjohannes.java-module-dependencies") | ||
id("org.gradlex.java-module-dependencies") | ||
} | ||
// Define versions for Modules via the Module Name | ||
|
@@ -254,7 +257,7 @@ commons-cli:commons-cli (1.5.0) | |
Notes / Options: | ||
- This may be ok if you use the Classpath (aka ALL-UNNAMED) in addition to the Module Path (automatic modules can see ALL-UNNAMED) | ||
- Remove the dependencies or upgrade to higher versions | ||
- Patch legacy Jars to Modules: https://github.com/jjohannes/extra-java-module-info | ||
- Patch legacy Jars to Modules: https://github.com/gradlex-org/extra-java-module-info | ||
``` | ||
|
||
## Migrate existing Java projects to Java Modules | ||
|
@@ -266,13 +269,13 @@ This is not a sophisticated migration tool, but useful, in combination with `ana | |
|
||
## Integration with the Extra Java Module Info plugin | ||
|
||
This plugin integrates with the [Extra Java Module Info](https://github.com/jjohannes/extra-java-module-info) plugin if both are applied. | ||
This plugin integrates with the [Extra Java Module Info](https://github.com/gradlex-org/extra-java-module-info) plugin if both are applied. | ||
Module Name mappings for Jars that were patched with extra module info will be automatically registered. | ||
|
||
``` | ||
plugins { | ||
id("de.jjohannes.extra-java-module-info") | ||
id("de.jjohannes.java-module-dependencies") | ||
id("org.gradlex.extra-java-module-info") | ||
id("org.gradlex.java-module-dependencies") | ||
} | ||
extraJavaModuleInfo { | ||
|
@@ -296,3 +299,7 @@ feature of Gradle, the result of the configuration phase is cached, avoiding par | |
org.gradle.unsafe.configuration-cache=true | ||
``` | ||
|
||
# Disclaimer | ||
|
||
Gradle and the Gradle logo are trademarks of Gradle, Inc. | ||
The GradleX project is not endorsed by, affiliated with, or associated with Gradle or Gradle, Inc. in any way. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,43 @@ | ||
plugins { | ||
id("de.jjohannes.gradle-plugin") | ||
id("gradlexbuild.module-mappings") | ||
id("groovy") | ||
id("org.gradlex.internal.plugin-publish-conventions") version "0.4" | ||
} | ||
|
||
group = "de.jjohannes.gradle" | ||
version = "0.11" | ||
group = "org.gradlex" | ||
version = "1.0" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
dependencies { | ||
implementation("org.ow2.asm:asm:8.0.1") | ||
|
||
compileOnly("de.jjohannes.gradle:extra-java-module-info:0.13") | ||
compileOnly("org.gradlex:extra-java-module-info:1.0") | ||
|
||
testImplementation("org.spockframework:spock-core:2.1-groovy-3.0") | ||
testImplementation("org.gradle.exemplar:samples-check:1.0.0") | ||
testRuntimeOnly("org.junit.vintage:junit-vintage-engine") | ||
} | ||
|
||
val pluginId = "de.jjohannes.java-module-dependencies" | ||
val pluginClass = "de.jjohannes.gradle.moduledependencies.JavaModuleDependenciesPlugin" | ||
val pluginName = "Java Module Dependencies Gradle Plugin" | ||
val pluginDescription = "A plugin that makes Gradle respect the dependencies defined in 'module-info.java' files." | ||
val pluginBundleTags = listOf("java", "modularity", "jigsaw", "jpms", "dependencies", "versions") | ||
val pluginGitHub = "https://github.com/jjohannes/java-module-dependencies" | ||
|
||
gradlePlugin { | ||
plugins { | ||
create(project.name) { | ||
id = pluginId | ||
implementationClass = pluginClass | ||
displayName = pluginName | ||
description = pluginDescription | ||
} | ||
pluginPublishConventions { | ||
id("${project.group}.${project.name}") | ||
implementationClass("org.gradlex.javamodule.dependencies.JavaModuleDependenciesPlugin") | ||
displayName("Java Module Dependencies Gradle Plugin") | ||
description("A plugin that makes Gradle respect the dependencies defined in 'module-info.java' files.") | ||
tags("gradlex", "java", "modularity", "jigsaw", "jpms", "dependencies", "versions") | ||
gitHub("https://github.com/gradlex-org/java-module-dependencies") | ||
developer { | ||
id.set("jjohannes") | ||
name.set("Jendrik Johannes") | ||
email.set("[email protected]") | ||
} | ||
} | ||
|
||
pluginBundle { | ||
website = pluginGitHub | ||
vcsUrl = pluginGitHub | ||
tags = pluginBundleTags | ||
} | ||
|
||
publishing { | ||
publications.withType<MavenPublication>().all { | ||
pom.name.set(pluginName) | ||
pom.description.set(pluginDescription) | ||
pom.url.set(pluginGitHub) | ||
pom.licenses { | ||
license { | ||
name.set("Apache License, Version 2.0") | ||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") | ||
} | ||
} | ||
pom.developers { | ||
developer { | ||
id.set("jjohannes") | ||
name.set("Jendrik Johannes") | ||
email.set("[email protected]") | ||
} | ||
} | ||
pom.scm { | ||
url.set(pluginGitHub) | ||
} | ||
} | ||
tasks.test { | ||
useJUnitPlatform() | ||
maxParallelForks = 4 | ||
inputs.dir(layout.projectDirectory.dir("samples")) | ||
} |
22 changes: 0 additions & 22 deletions
22
gradle-build-logic/src/main/kotlin/de.jjohannes.gradle-plugin.gradle.kts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE module PUBLIC | ||
"-//Puppy Crawl//DTD Check Configuration 1.2//EN" | ||
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> | ||
<module name="Checker"> | ||
<module name="Header"> | ||
<property name="headerFile" value="${config_loc}/header.txt"/> | ||
</module> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright 2022 the GradleX team. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ |
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
gradle/plugins/src/main/kotlin/gradlexbuild.module-mappings.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import gradlexbuild.UniqueModulesPropertiesUpdate | ||
|
||
plugins { | ||
id("base") | ||
} | ||
|
||
val updateUniqueModulesProperties = tasks.register<UniqueModulesPropertiesUpdate>("updateUniqueModulesProperties") | ||
|
||
tasks.assemble { | ||
dependsOn(updateUniqueModulesProperties) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
samples/configuration-cache/build-logic/src/main/kotlin/org.my.gradle.java-module.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
samples/kotlin/build-logic/src/main/kotlin/org.my.gradle.kotlin-java-module.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
samples/versions-in-catalog/build-logic/src/main/kotlin/org.my.gradle.java-module.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...les/versions-in-platform/build-logic/src/main/kotlin/org.my.gradle.java-module.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
samples/versions-in-platform/build-logic/src/main/kotlin/org.my.gradle.platform.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.