Skip to content

Commit 828846f

Browse files
committed
Format code
1 parent 962bd89 commit 828846f

File tree

66 files changed

+1423
-1916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1423
-1916
lines changed

src/main/java/org/gradlex/javamodule/dependencies/JDKInfo.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
1-
/*
2-
* Copyright the GradleX team.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
1+
// SPDX-License-Identifier: Apache-2.0
172
package org.gradlex.javamodule.dependencies;
183

194
import java.util.Arrays;
@@ -82,6 +67,5 @@ interface JDKInfo {
8267
"jdk.unsupported",
8368
"jdk.unsupported.desktop",
8469
"jdk.xml.dom",
85-
"jdk.zipfs"
86-
);
70+
"jdk.zipfs");
8771
}

src/main/java/org/gradlex/javamodule/dependencies/JavaModuleDependenciesExtension.java

Lines changed: 134 additions & 96 deletions
Large diffs are not rendered by default.

src/main/java/org/gradlex/javamodule/dependencies/JavaModuleDependenciesPlugin.java

Lines changed: 237 additions & 109 deletions
Large diffs are not rendered by default.

src/main/java/org/gradlex/javamodule/dependencies/JavaModuleVersionsPlugin.java

Lines changed: 68 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
/*
2-
* Copyright the GradleX team.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
1+
// SPDX-License-Identifier: Apache-2.0
172
package org.gradlex.javamodule.dependencies;
183

4+
import static org.gradle.api.attributes.Usage.JAVA_RUNTIME;
5+
import static org.gradle.api.plugins.JavaPlatformPlugin.API_CONFIGURATION_NAME;
6+
import static org.gradlex.javamodule.dependencies.internal.utils.ModuleInfo.Directive.REQUIRES;
7+
import static org.gradlex.javamodule.dependencies.internal.utils.ModuleInfo.Directive.REQUIRES_RUNTIME;
8+
import static org.gradlex.javamodule.dependencies.internal.utils.ModuleInfo.Directive.REQUIRES_STATIC;
9+
import static org.gradlex.javamodule.dependencies.internal.utils.ModuleInfo.Directive.REQUIRES_STATIC_TRANSITIVE;
10+
import static org.gradlex.javamodule.dependencies.internal.utils.ModuleInfo.Directive.REQUIRES_TRANSITIVE;
11+
12+
import java.io.File;
13+
import java.util.Arrays;
14+
import java.util.List;
15+
import java.util.stream.Collectors;
16+
import java.util.stream.Stream;
1917
import org.gradle.api.Plugin;
2018
import org.gradle.api.Project;
2119
import org.gradle.api.artifacts.Configuration;
@@ -31,23 +29,10 @@
3129
import org.gradlex.javamodule.dependencies.tasks.CatalogGenerate;
3230
import org.jspecify.annotations.Nullable;
3331

34-
import java.io.File;
35-
import java.util.Arrays;
36-
import java.util.List;
37-
import java.util.stream.Collectors;
38-
import java.util.stream.Stream;
39-
40-
import static org.gradle.api.attributes.Usage.JAVA_RUNTIME;
41-
import static org.gradle.api.plugins.JavaPlatformPlugin.API_CONFIGURATION_NAME;
42-
import static org.gradlex.javamodule.dependencies.internal.utils.ModuleInfo.Directive.REQUIRES;
43-
import static org.gradlex.javamodule.dependencies.internal.utils.ModuleInfo.Directive.REQUIRES_RUNTIME;
44-
import static org.gradlex.javamodule.dependencies.internal.utils.ModuleInfo.Directive.REQUIRES_STATIC;
45-
import static org.gradlex.javamodule.dependencies.internal.utils.ModuleInfo.Directive.REQUIRES_STATIC_TRANSITIVE;
46-
import static org.gradlex.javamodule.dependencies.internal.utils.ModuleInfo.Directive.REQUIRES_TRANSITIVE;
47-
4832
@SuppressWarnings("unused")
4933
public abstract class JavaModuleVersionsPlugin implements Plugin<Project> {
50-
private static final boolean MIN_GRADLE_9_0 = GradleVersion.current().compareTo(GradleVersion.version("9.0.0")) >= 0;
34+
private static final boolean MIN_GRADLE_9_0 =
35+
GradleVersion.current().compareTo(GradleVersion.version("9.0.0")) >= 0;
5136

5237
@Override
5338
public void apply(Project project) {
@@ -81,9 +66,14 @@ private void setupForJavaProject(Project project) {
8166

8267
if (GradleVersion.current().compareTo(GradleVersion.version("8.6")) < 0) {
8368
// https://github.com/gradle/gradle/issues/26163
84-
project.afterEvaluate(p -> platformElements.getOutgoing().capability(project.getGroup() + ":" + project.getName() + "-platform:" + project.getVersion()));
69+
project.afterEvaluate(p -> platformElements
70+
.getOutgoing()
71+
.capability(project.getGroup() + ":" + project.getName() + "-platform:" + project.getVersion()));
8572
} else {
86-
platformElements.getOutgoing().capability(project.provider(() -> project.getGroup() + ":" + project.getName() + "-platform:" + project.getVersion()));
73+
platformElements
74+
.getOutgoing()
75+
.capability(project.provider(
76+
() -> project.getGroup() + ":" + project.getName() + "-platform:" + project.getVersion()));
8777
}
8878

8979
setupVersionsDSL(project, versions);
@@ -93,18 +83,24 @@ private void setupForJavaProject(Project project) {
9383

9484
private void setupVersionsDSL(Project project, Configuration configuration) {
9585
project.getPlugins().apply(JavaModuleDependenciesPlugin.class);
96-
JavaModuleDependenciesExtension javaModuleDependencies = project.getExtensions().getByType(JavaModuleDependenciesExtension.class);
86+
JavaModuleDependenciesExtension javaModuleDependencies =
87+
project.getExtensions().getByType(JavaModuleDependenciesExtension.class);
9788
project.getExtensions().create("moduleInfo", ModuleVersions.class, configuration, javaModuleDependencies);
9889
}
9990

10091
private void setupConstraintsValidation(Project project, Configuration configuration) {
10192
configuration.getDependencyConstraints().configureEach(d -> {
102-
JavaModuleDependenciesExtension javaModuleDependencies = project.getExtensions().getByType(JavaModuleDependenciesExtension.class);
93+
JavaModuleDependenciesExtension javaModuleDependencies =
94+
project.getExtensions().getByType(JavaModuleDependenciesExtension.class);
10395
String userDefinedReason = d.getReason();
10496
String ga = d.getModule().toString();
10597
Provider<String> moduleName = javaModuleDependencies.moduleName(ga);
106-
if (moduleName.isPresent() && isModuleName(userDefinedReason) && !moduleName.get().equals(userDefinedReason)) {
107-
project.getLogger().lifecycle("WARN: Expected module name for '" + ga + "' is '" + moduleName.get() + "' (not '" + userDefinedReason + "')");
98+
if (moduleName.isPresent()
99+
&& isModuleName(userDefinedReason)
100+
&& !moduleName.get().equals(userDefinedReason)) {
101+
project.getLogger()
102+
.lifecycle("WARN: Expected module name for '" + ga + "' is '" + moduleName.get() + "' (not '"
103+
+ userDefinedReason + "')");
108104
}
109105
});
110106
}
@@ -114,7 +110,8 @@ private boolean isModuleName(@Nullable String s) {
114110
}
115111

116112
private void registerCatalogTask(Project project) {
117-
JavaModuleDependenciesExtension javaModuleDependencies = project.getExtensions().getByType(JavaModuleDependenciesExtension.class);
113+
JavaModuleDependenciesExtension javaModuleDependencies =
114+
project.getExtensions().getByType(JavaModuleDependenciesExtension.class);
118115
ModuleVersions moduleVersions = project.getExtensions().getByType(ModuleVersions.class);
119116
project.getTasks().register("generateCatalog", CatalogGenerate.class, t -> {
120117
t.setGroup("java modules");
@@ -131,12 +128,27 @@ private void registerCatalogTask(Project project) {
131128
moduleInfoFile = new File(srcDirSet, "java9/module-info.java");
132129
}
133130
if (moduleInfoFile.exists()) {
134-
ModuleInfo moduleInfo = new ModuleInfo(project.getProviders().fileContents(project.getLayout().getProjectDirectory().file(moduleInfoFile.getAbsolutePath())).getAsText().get());
135-
t.getEntries().addAll(collectCatalogEntriesFromModuleInfos(javaModuleDependencies, moduleInfo.get(REQUIRES_TRANSITIVE)));
136-
t.getEntries().addAll(collectCatalogEntriesFromModuleInfos(javaModuleDependencies, moduleInfo.get(REQUIRES)));
137-
t.getEntries().addAll(collectCatalogEntriesFromModuleInfos(javaModuleDependencies, moduleInfo.get(REQUIRES_STATIC_TRANSITIVE)));
138-
t.getEntries().addAll(collectCatalogEntriesFromModuleInfos(javaModuleDependencies, moduleInfo.get(REQUIRES_STATIC)));
139-
t.getEntries().addAll(collectCatalogEntriesFromModuleInfos(javaModuleDependencies, moduleInfo.get(REQUIRES_RUNTIME)));
131+
ModuleInfo moduleInfo = new ModuleInfo(project.getProviders()
132+
.fileContents(project.getLayout()
133+
.getProjectDirectory()
134+
.file(moduleInfoFile.getAbsolutePath()))
135+
.getAsText()
136+
.get());
137+
t.getEntries()
138+
.addAll(collectCatalogEntriesFromModuleInfos(
139+
javaModuleDependencies, moduleInfo.get(REQUIRES_TRANSITIVE)));
140+
t.getEntries()
141+
.addAll(collectCatalogEntriesFromModuleInfos(
142+
javaModuleDependencies, moduleInfo.get(REQUIRES)));
143+
t.getEntries()
144+
.addAll(collectCatalogEntriesFromModuleInfos(
145+
javaModuleDependencies, moduleInfo.get(REQUIRES_STATIC_TRANSITIVE)));
146+
t.getEntries()
147+
.addAll(collectCatalogEntriesFromModuleInfos(
148+
javaModuleDependencies, moduleInfo.get(REQUIRES_STATIC)));
149+
t.getEntries()
150+
.addAll(collectCatalogEntriesFromModuleInfos(
151+
javaModuleDependencies, moduleInfo.get(REQUIRES_RUNTIME)));
140152
}
141153
});
142154
});
@@ -147,12 +159,20 @@ private void registerCatalogTask(Project project) {
147159
});
148160
}
149161

150-
private List<CatalogGenerate.CatalogEntry> collectCatalogEntriesFromVersions(JavaModuleDependenciesExtension javaModuleDependencies, ModuleVersions moduleVersions) {
151-
return moduleVersions.getDeclaredVersions().entrySet().stream().map(mv -> new CatalogGenerate.CatalogEntry(mv.getKey(), javaModuleDependencies.ga(mv.getKey()), mv.getValue())).collect(Collectors.toList());
162+
private List<CatalogGenerate.CatalogEntry> collectCatalogEntriesFromVersions(
163+
JavaModuleDependenciesExtension javaModuleDependencies, ModuleVersions moduleVersions) {
164+
return moduleVersions.getDeclaredVersions().entrySet().stream()
165+
.map(mv -> new CatalogGenerate.CatalogEntry(
166+
mv.getKey(), javaModuleDependencies.ga(mv.getKey()), mv.getValue()))
167+
.collect(Collectors.toList());
152168
}
153169

154-
private List<CatalogGenerate.CatalogEntry> collectCatalogEntriesFromModuleInfos(JavaModuleDependenciesExtension javaModuleDependencies, List<String> moduleNames) {
155-
return moduleNames.stream().map(moduleName -> new CatalogGenerate.CatalogEntry(moduleName, javaModuleDependencies.ga(moduleName), null)).collect(Collectors.toList());
170+
private List<CatalogGenerate.CatalogEntry> collectCatalogEntriesFromModuleInfos(
171+
JavaModuleDependenciesExtension javaModuleDependencies, List<String> moduleNames) {
172+
return moduleNames.stream()
173+
.map(moduleName ->
174+
new CatalogGenerate.CatalogEntry(moduleName, javaModuleDependencies.ga(moduleName), null))
175+
.collect(Collectors.toList());
156176
}
157177

158178
@SuppressWarnings("deprecation")

src/main/java/org/gradlex/javamodule/dependencies/LocalModule.java

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
1-
/*
2-
* Copyright the GradleX team.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
1+
// SPDX-License-Identifier: Apache-2.0
172
package org.gradlex.javamodule.dependencies;
183

19-
import org.jspecify.annotations.Nullable;
20-
214
import java.io.Serializable;
225
import java.util.Objects;
6+
import org.jspecify.annotations.Nullable;
237

248
public class LocalModule implements Comparable<LocalModule>, Serializable {
259
private final String moduleName;
2610
private final String projectPath;
11+
2712
@Nullable
2813
private final String capability;
2914

@@ -57,11 +42,10 @@ public String getCapability() {
5742

5843
@Override
5944
public String toString() {
60-
return "[" +
61-
"moduleName='" + moduleName + '\'' +
62-
", projectPath='" + projectPath + '\'' +
63-
", capability='" + capability + '\'' +
64-
']';
45+
return "[" + "moduleName='"
46+
+ moduleName + '\'' + ", projectPath='"
47+
+ projectPath + '\'' + ", capability='"
48+
+ capability + '\'' + ']';
6549
}
6650

6751
@Override
Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
1-
/*
2-
* Copyright the GradleX team.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
1+
// SPDX-License-Identifier: Apache-2.0
172
package org.gradlex.javamodule.dependencies;
183

19-
import org.jspecify.annotations.Nullable;
20-
214
import java.io.IOException;
225
import java.io.InputStream;
236
import java.util.Map;
247
import java.util.Properties;
8+
import org.jspecify.annotations.Nullable;
259

26-
final public class SharedMappings {
10+
public final class SharedMappings {
2711
public static Map<String, String> mappings = loadModuleNameToGAProperties();
2812

2913
static Map<String, String> loadModuleNameToGAProperties() {
@@ -36,22 +20,24 @@ static Map<String, String> loadModuleNameToGAProperties() {
3620
return super.put(key, value);
3721
}
3822
};
39-
@SuppressWarnings({ "unchecked", "rawtypes" })
23+
@SuppressWarnings({"unchecked", "rawtypes"})
4024
Map<String, String> propertiesAsMap = (Map) properties;
4125

42-
try (InputStream coordinatesFile = JavaModuleDependenciesExtension.class.getResourceAsStream("unique_modules.properties")) {
26+
try (InputStream coordinatesFile =
27+
JavaModuleDependenciesExtension.class.getResourceAsStream("unique_modules.properties")) {
4328
properties.load(coordinatesFile);
4429
} catch (IOException e) {
4530
throw new RuntimeException(e);
4631
}
4732

48-
try (InputStream coordinatesFile = JavaModuleDependenciesExtension.class.getResourceAsStream("modules.properties")) {
33+
try (InputStream coordinatesFile =
34+
JavaModuleDependenciesExtension.class.getResourceAsStream("modules.properties")) {
4935
properties.load(coordinatesFile);
5036
} catch (IOException e) {
5137
throw new RuntimeException(e);
5238
}
5339
return propertiesAsMap;
5440
}
5541

56-
private SharedMappings() { }
42+
private SharedMappings() {}
5743
}

src/main/java/org/gradlex/javamodule/dependencies/dsl/AllDirectives.java

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
1-
/*
2-
* Copyright the GradleX team.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
1+
// SPDX-License-Identifier: Apache-2.0
172
package org.gradlex.javamodule.dependencies.dsl;
183

194
import org.gradle.api.tasks.SourceSet;
205
import org.gradlex.javamodule.dependencies.JavaModuleDependenciesExtension;
216

22-
abstract public class AllDirectives extends GradleOnlyDirectives {
7+
public abstract class AllDirectives extends GradleOnlyDirectives {
238

24-
public AllDirectives(SourceSet sourceSet, SourceSet mainSourceSet, JavaModuleDependenciesExtension javaModuleDependencies) {
9+
public AllDirectives(
10+
SourceSet sourceSet, SourceSet mainSourceSet, JavaModuleDependenciesExtension javaModuleDependencies) {
2511
super(sourceSet, mainSourceSet, javaModuleDependencies);
2612
}
2713

src/main/java/org/gradlex/javamodule/dependencies/dsl/GradleOnlyDirectives.java

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
1-
/*
2-
* Copyright the GradleX team.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
1+
// SPDX-License-Identifier: Apache-2.0
172
package org.gradlex.javamodule.dependencies.dsl;
183

4+
import java.util.ArrayList;
5+
import java.util.List;
6+
import javax.inject.Inject;
197
import org.gradle.api.artifacts.dsl.DependencyHandler;
208
import org.gradle.api.tasks.SourceSet;
219
import org.gradlex.javamodule.dependencies.JavaModuleDependenciesExtension;
2210

23-
import javax.inject.Inject;
24-
import java.util.ArrayList;
25-
import java.util.List;
26-
2711
public abstract class GradleOnlyDirectives {
2812

2913
protected final SourceSet sourceSet;
@@ -38,7 +22,8 @@ public abstract class GradleOnlyDirectives {
3822
@Inject
3923
protected abstract DependencyHandler getDependencies();
4024

41-
public GradleOnlyDirectives(SourceSet sourceSet, SourceSet mainSourceSet, JavaModuleDependenciesExtension javaModuleDependencies) {
25+
public GradleOnlyDirectives(
26+
SourceSet sourceSet, SourceSet mainSourceSet, JavaModuleDependenciesExtension javaModuleDependencies) {
4227
this.sourceSet = sourceSet;
4328
this.mainSourceSet = mainSourceSet;
4429
this.javaModuleDependencies = javaModuleDependencies;

0 commit comments

Comments
 (0)