Skip to content

Commit

Permalink
Version 1.0 - move to 'org.gradlex'
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohannes committed Aug 18, 2022
1 parent c15e375 commit ab9135d
Show file tree
Hide file tree
Showing 45 changed files with 448 additions and 204 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Java Module Dependencies Gradle Plugin - Changelog

## Version 1.0
* Moved project to [GradleX](https://gradlex.org) - new plugin ID: `org.gradlex.java-module-dependencies`

## Versions 0.11
* [#18](https://github.com/jjohannes/java-module-dependencies/issues/18) Fix bug with single line comments in module-info.java
* [#18](https://github.com/gradlex-org/java-module-dependencies/issues/18) Fix bug with single line comments in module-info.java
* More mappings for Modules on Maven Central

## Versions 0.10
Expand Down
41 changes: 24 additions & 17 deletions README.MD
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
Expand All @@ -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.
Expand All @@ -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")
}
```

Expand All @@ -66,7 +69,7 @@ In your convention plugin, apply the plugin.
```
plugins {
...
id("de.jjohannes.java-module-dependencies")
id("org.gradlex.java-module-dependencies")
}
```

Expand All @@ -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:

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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.
72 changes: 25 additions & 47 deletions build.gradle.kts
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"))
}

This file was deleted.

8 changes: 8 additions & 0 deletions gradle/checkstyle/checkstyle.xml
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>
15 changes: 15 additions & 0 deletions gradle/checkstyle/header.txt
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.
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)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.jjohannes.gradle.moduledependencies.gradlebuild.tasks
package gradlexbuild

import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.ExternalModuleDependency
Expand All @@ -19,7 +19,7 @@ abstract class UniqueModulesPropertiesUpdate : DefaultTask() {
val name = split[split.size - 3]
"${entry.key}=$group:$name\n"
}.joinToString("")
project.layout.projectDirectory.file("src/main/resources/de/jjohannes/gradle/moduledependencies/unique_modules.properties").asFile.writeText(modulesToCoordinates.trim())
project.layout.projectDirectory.file("src/main/resources/org/gradlex/javamodule/dependencies/unique_modules.properties").asFile.writeText(modulesToCoordinates.trim())
}

private fun getModulesPropertiesFromRepository(): File {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
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
2 changes: 1 addition & 1 deletion samples/configuration-cache/build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ plugins {
}

dependencies {
implementation("de.jjohannes.gradle:java-module-dependencies:0.11")
implementation("org.gradlex:java-module-dependencies:1.0")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java")
id("de.jjohannes.java-module-dependencies")
id("org.gradlex.java-module-dependencies")
}

group = "org.my"
Expand Down
2 changes: 1 addition & 1 deletion samples/kotlin/build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ plugins {
}

dependencies {
implementation("de.jjohannes.gradle:java-module-dependencies:0.11")
implementation("org.gradlex:java-module-dependencies:1.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("de.jjohannes.java-module-dependencies")
id("org.gradlex.java-module-dependencies")
id("org.jetbrains.kotlin.jvm")
}

Expand Down
2 changes: 1 addition & 1 deletion samples/versions-in-catalog/build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ plugins {
}

dependencies {
implementation("de.jjohannes.gradle:java-module-dependencies:0.11")
implementation("org.gradlex:java-module-dependencies:1.0")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java")
id("de.jjohannes.java-module-dependencies")
id("org.gradlex.java-module-dependencies")
}

group = "org.my"
Expand Down
2 changes: 1 addition & 1 deletion samples/versions-in-platform/build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ plugins {
}

dependencies {
implementation("de.jjohannes.gradle:java-module-dependencies:0.11")
implementation("org.gradlex:java-module-dependencies:1.0")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java")
id("de.jjohannes.java-module-dependencies")
id("org.gradlex.java-module-dependencies")
}

group = "org.my"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java-platform")
id("de.jjohannes.java-module-dependencies")
id("org.gradlex.java-module-dependencies")
}

group = "org.my"
Expand Down
Loading

0 comments on commit ab9135d

Please sign in to comment.