Skip to content

Commit

Permalink
[#1611] make picocli-groovy a named JPMS module with a `module-info…
Browse files Browse the repository at this point in the history
….class`

Closes #1611
  • Loading branch information
remkop committed Feb 26, 2022
1 parent c7820b5 commit 09b3acb
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 3 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Picocli 4.7.0 introduced a `sortSynopsis = false` attribute to let the synopsis

## <a name="4.7.0-fixes"></a> Fixed issues
* [#1599] API: The `picocli-codegen` artifact is now a named JPMS module with a `module-info.class`.
* [#1611] API: The `picocli-groovy` artifact is now a named JPMS module with a `module-info.class`.
* [#1600] API: Add `requires static java.sql` to picocli `module-info`.
* [#1471] API: Provide a programmatic way to configure Picocli's `TraceLevel`. Thanks to [ekinano](https://github.com/ekinano) for raising this.
* [#1125] API: Add parser configuration to allow options to consume values that match subcommand names or option names.
Expand Down
26 changes: 25 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ buildscript {
}
}

apply plugin: "org.beryx.jar"
apply plugin: 'io.codearte.nexus-staging'

if (System.getenv('MAVEN_OSS_USER')) { // on home system
Expand Down Expand Up @@ -61,6 +60,7 @@ pluginManager.withPlugin('biz.aQute.bnd.builder') { // if plugin applied, execut
allprojects {
apply plugin: 'java'
apply plugin: 'java-library' // to avoid https://github.com/gradle/gradle/issues/1118
apply plugin: "org.beryx.jar" // for compiling module-info on Java 8

sourceCompatibility = !JavaVersion.current().isJava9Compatible() ?
1.5 : JavaVersion.current().isJava11Compatible() ? 1.7 : 1.6
Expand Down Expand Up @@ -103,6 +103,29 @@ allprojects {
into 'build/docs/apidocs'
include '**/doc-files/*.*'
}
//sourceSets.main.java.srcDirs = ['src/main/java', 'src/main/java9']
compileJava {
inputs.property("moduleName", moduleName)
// doFirst {
// logger.info("Java version is " + JavaVersion.current())
// if (JavaVersion.current().isJava9Compatible()) {
// options.compilerArgs = [
// '--module-path', classpath.asPath,
// ]
// }
// // classpath = files()
// classpath = sourceSets.main.runtimeClasspath
// logger.info("options.compilerArgs is " + options.compilerArgs)
// logger.info("classpath is " + classpath.files)
// }
}
moduleConfig {
// copy module-info.class to META-INF/versions/9
multiReleaseVersion = 9
moduleInfoPath = 'src/main/java9/module-info.java'
version = project.version
neverCompileModuleInfo = true
}
}

//sourceSets.main.java.srcDirs = ['src/main/java', 'src/main/java9']
Expand Down Expand Up @@ -163,6 +186,7 @@ configurations {
// - Unmatched attribute:
// - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, new Integer(JavaVersion.VERSION_1_6.majorVersion))

}
}
}
Expand Down
4 changes: 2 additions & 2 deletions picocli-groovy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
group 'info.picocli'
description 'Picocli Groovy - easily use picocli in Groovy scripts.'
version "$projectVersion"
ext.moduleName = 'info.picocli.groovy'

configurations {
ivy
Expand Down Expand Up @@ -35,8 +36,7 @@ jar {
'Specification-Version' : archiveVersion.get(),
'Implementation-Title' : 'Picocli Groovy',
'Implementation-Vendor' : 'Remko Popma',
'Implementation-Version': archiveVersion.get(),
'Automatic-Module-Name' : 'info.picocli.groovy'
'Implementation-Version': archiveVersion.get()
}
}

Expand Down
37 changes: 37 additions & 0 deletions picocli-groovy/src/main/java9/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright 2017 Remko Popma
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.
*/

// When compiling in Gradle, the org.beryx.jar plugin will be able to
// compile this file even with Java versions 8 or older.

// Your IDE may complain that "Modules are not supported at language level '5'",
// and javac may give an error: "java: class, interface or enum expected".
// To resolve this, exclude the 'java9' folder from the sources.
// IntelliJ IDEA:
// File > Project Structure... > Modules > picocli_main > Sources:
// select the 'java9' folder and click 'Mark as: Excluded'.

/**
* Defines API and implementation for building command line (CLI) applications with Groovy scripts.
*
* @since 4.7.0
*/
module info.picocli.groovy {
requires info.picocli;
requires groovy.all;

exports picocli.groovy;
}

0 comments on commit 09b3acb

Please sign in to comment.