Skip to content

Commit e201c89

Browse files
committed
Streamline API details and add more Javadoc
1 parent d86c4dc commit e201c89

File tree

6 files changed

+83
-12
lines changed

6 files changed

+83
-12
lines changed

build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ java {
1616
sourceCompatibility = JavaVersion.VERSION_1_8
1717
targetCompatibility = JavaVersion.VERSION_1_8
1818
}
19-
tasks.javadoc {
20-
(options as CoreJavadocOptions).addStringOption("Xdoclint:none", "-quiet")
21-
}
22-
2319
val functionalTest: SourceSet by sourceSets.creating
2420
gradlePlugin.testSourceSets(functionalTest)
2521
val functionalTestTask = tasks.register<Test>("functionalTest") {

src/main/java/de/jjohannes/gradle/javamodules/AutomaticModuleName.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public class AutomaticModuleName extends ModuleSpec {
44

5-
public AutomaticModuleName(String identifier, String moduleName) {
5+
AutomaticModuleName(String identifier, String moduleName) {
66
super(identifier, moduleName);
77
}
88
}

src/main/java/de/jjohannes/gradle/javamodules/ExtraModuleInfoPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Entry point of the plugin.
1515
*/
1616
@SuppressWarnings("unused")
17+
@NonNullApi
1718
public class ExtraModuleInfoPlugin implements Plugin<Project> {
1819

1920
@Override

src/main/java/de/jjohannes/gradle/javamodules/ExtraModuleInfoPluginExtension.java

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,45 @@ public abstract class ExtraModuleInfoPluginExtension {
1818

1919
/**
2020
* Add full module information for a given Jar file.
21+
*
22+
* @param identifier group:name coordinates _or_ Jar file name
23+
* @param moduleName the Module Name of the Module to construct
24+
*/
25+
public void module(String identifier, String moduleName) {
26+
module(identifier, moduleName, null, null);
27+
}
28+
29+
/**
30+
* Add full module information for a given Jar file.
31+
*
32+
* @param identifier group:name coordinates _or_ Jar file name
33+
* @param moduleName the Module Name of the Module to construct
34+
* @param moduleVersion version to write into the module-info.class
2135
*/
2236
public void module(String identifier, String moduleName, String moduleVersion) {
2337
module(identifier, moduleName, moduleVersion, null);
2438
}
2539

2640
/**
27-
* Add full module information, including exported packages and dependencies, for a given Jar file.
41+
* Add full module information for a given Jar file.
42+
*
43+
* @param identifier group:name coordinates _or_ Jar file name
44+
* @param moduleName the Module Name of the Module to construct
45+
* @param conf configure exported packages and dependencies, see {@link ModuleInfo}
46+
*/
47+
public void module(String identifier, String moduleName, @Nullable Action<? super ModuleInfo> conf) {
48+
module(identifier, moduleName, null, conf);
49+
}
50+
51+
/**
52+
* Add full module information for a given Jar file.
53+
*
54+
* @param identifier group:name coordinates _or_ Jar file name
55+
* @param moduleName the Module Name of the Module to construct
56+
* @param moduleVersion version to write into the module-info.class
57+
* @param conf configure exported packages, dependencies and Jar merging, see {@link ModuleInfo}
2858
*/
29-
public void module(String identifier, String moduleName, String moduleVersion, @Nullable Action<? super ModuleInfo> conf) {
59+
public void module(String identifier, String moduleName, @Nullable String moduleVersion, @Nullable Action<? super ModuleInfo> conf) {
3060
ModuleInfo moduleInfo = new ModuleInfo(identifier, moduleName, moduleVersion);
3161
if (conf != null) {
3262
conf.execute(moduleInfo);
@@ -35,16 +65,23 @@ public void module(String identifier, String moduleName, String moduleVersion, @
3565
}
3666

3767
/**
38-
* Add only an automatic module name to a given jar file.
68+
* Add an Automatic-Module-Name to a given Jar file.
69+
*
70+
* @param identifier group:name coordinates _or_ Jar file name
71+
* @param moduleName the Module Name of the Module to construct
3972
*/
4073
public void automaticModule(String identifier, String moduleName) {
4174
automaticModule(identifier, moduleName, null);
4275
}
4376

4477
/**
45-
* Add only an automatic module name to a given jar file.
78+
* Add an Automatic-Module-Name to a given Jar file.
79+
*
80+
* @param identifier group:name coordinates _or_ Jar file name
81+
* @param moduleName the Module Name of the Module to construct
82+
* @param conf configure Jar merging, see {@link AutomaticModuleName}
4683
*/
47-
public void automaticModule(String identifier, String moduleName, @Nullable Action<? super ModuleSpec> conf) {
84+
public void automaticModule(String identifier, String moduleName, @Nullable Action<? super AutomaticModuleName> conf) {
4885
AutomaticModuleName automaticModuleName = new AutomaticModuleName(identifier, moduleName);
4986
if (conf != null) {
5087
conf.execute(automaticModuleName);

src/main/java/de/jjohannes/gradle/javamodules/ModuleInfo.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
public class ModuleInfo extends ModuleSpec {
1010

11-
protected final String moduleVersion;
11+
private final String moduleVersion;
1212

1313
final Set<String> exports = new LinkedHashSet<>();
1414
final Set<String> requires = new LinkedHashSet<>();
@@ -21,26 +21,48 @@ public class ModuleInfo extends ModuleSpec {
2121
this.moduleVersion = moduleVersion;
2222
}
2323

24+
/**
25+
* @param exports corresponds to the directive in a 'module-info.java' file
26+
*/
2427
public void exports(String exports) {
2528
addOrThrow(this.exports, exports);
2629
}
2730

31+
/**
32+
* @param requires corresponds to the directive in a 'module-info.java' file
33+
*/
2834
public void requires(String requires) {
2935
addOrThrow(this.requires, requires);
3036
}
3137

38+
/**
39+
* @param requiresTransitive corresponds to the directive in a 'module-info.java' file
40+
*/
3241
public void requiresTransitive(String requiresTransitive) {
3342
addOrThrow(this.requiresTransitive, requiresTransitive);
3443
}
3544

45+
/**
46+
* @param requiresStatic corresponds to the directive in a 'module-info.java' file
47+
*/
3648
public void requiresStatic(String requiresStatic) {
3749
addOrThrow(this.requiresStatic, requiresStatic);
3850
}
3951

52+
/**
53+
* @param ignoreServiceProvider do not transfer service provider to the 'module-info.class'
54+
*/
4055
public void ignoreServiceProvider(String ignoreServiceProvider) {
4156
addOrThrow(this.ignoreServiceProviders, ignoreServiceProvider);
4257
}
4358

59+
/**
60+
* @return configured version of the Module
61+
*/
62+
public String getModuleVersion() {
63+
return moduleVersion;
64+
}
65+
4466
private static void addOrThrow(Set<String> target, String element) {
4567
if (!target.add(element)) {
4668
throw new IllegalArgumentException("The element '" + element + "' is already specified");

src/main/java/de/jjohannes/gradle/javamodules/ModuleSpec.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,44 @@
44
import java.util.ArrayList;
55
import java.util.List;
66

7+
/**
8+
* Details that real Modules and Automatic-Module-Names share.
9+
*/
710
abstract public class ModuleSpec implements Serializable {
811

912
private final String identifier;
1013
private final String moduleName;
1114
private final List<String> mergedJars = new ArrayList<>();
1215

13-
public ModuleSpec(String identifier, String moduleName) {
16+
ModuleSpec(String identifier, String moduleName) {
1417
this.identifier = identifier;
1518
this.moduleName = moduleName;
1619
}
1720

21+
/**
22+
* @return group:name coordinates _or_ Jar file name
23+
*/
1824
public String getIdentifier() {
1925
return identifier;
2026
}
2127

28+
/**
29+
* @return Module Name of the Module to construct
30+
*/
2231
public String getModuleName() {
2332
return moduleName;
2433
}
2534

35+
/**
36+
* @param identifier group:name coordinates _or_ Jar file name (of the Jar file to merge)
37+
*/
2638
public void mergeJar(String identifier) {
2739
mergedJars.add(identifier);
2840
}
2941

42+
/**
43+
* @return all merged Jar identifiers
44+
*/
3045
public List<String> getMergedJars() {
3146
return mergedJars;
3247
}

0 commit comments

Comments
 (0)