Skip to content

Commit d89833c

Browse files
committed
Format code
1 parent d1461ab commit d89833c

10 files changed

+213
-277
lines changed

src/main/java/org/gradlex/javamodule/testing/JavaModuleTestingExtension.java

Lines changed: 147 additions & 84 deletions
Large diffs are not rendered by default.
Lines changed: 3 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.testing;
183

194
import org.gradle.api.Plugin;
@@ -31,7 +16,7 @@ public void apply(Project project) {
3116
if (GradleVersion.current().compareTo(GradleVersion.version("7.4")) < 0) {
3217
throw new RuntimeException("This plugin requires Gradle 7.4+");
3318
}
34-
project.getPlugins().withType(JvmTestSuitePlugin.class, p->
35-
project.getExtensions().create("javaModuleTesting", JavaModuleTestingExtension.class));
19+
project.getPlugins().withType(JvmTestSuitePlugin.class, p -> project.getExtensions()
20+
.create("javaModuleTesting", JavaModuleTestingExtension.class));
3621
}
3722
}

src/main/java/org/gradlex/javamodule/testing/TaskLockService.java

Lines changed: 1 addition & 16 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.testing;
183

194
import org.gradle.api.services.BuildService;

src/main/java/org/gradlex/javamodule/testing/WhiteboxJvmTestSuite.java

Lines changed: 1 addition & 16 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.testing;
183

194
import org.gradle.api.provider.ListProperty;

src/main/java/org/gradlex/javamodule/testing/internal/ModuleInfoParser.java

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +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.testing.internal;
183

19-
import org.gradle.api.file.ProjectLayout;
20-
import org.gradle.api.file.RegularFile;
21-
import org.gradle.api.provider.Provider;
22-
import org.gradle.api.provider.ProviderFactory;
23-
244
import java.io.File;
255
import java.util.Arrays;
266
import java.util.List;
277
import java.util.Set;
8+
import org.gradle.api.file.ProjectLayout;
9+
import org.gradle.api.file.RegularFile;
10+
import org.gradle.api.provider.Provider;
11+
import org.gradle.api.provider.ProviderFactory;
2812

2913
public class ModuleInfoParser {
3014

@@ -38,8 +22,10 @@ public ModuleInfoParser(ProjectLayout layout, ProviderFactory providers) {
3822

3923
public String moduleName(Set<File> sourceFolders) {
4024
for (File folder : sourceFolders) {
41-
Provider<RegularFile> moduleInfoFile = layout.file(providers.provider(() -> new File(folder, "module-info.java")));
42-
Provider<String> moduleInfoContent = providers.fileContents(moduleInfoFile).getAsText();
25+
Provider<RegularFile> moduleInfoFile =
26+
layout.file(providers.provider(() -> new File(folder, "module-info.java")));
27+
Provider<String> moduleInfoContent =
28+
providers.fileContents(moduleInfoFile).getAsText();
4329
if (moduleInfoContent.isPresent()) {
4430
return moduleName(moduleInfoContent.get());
4531
}
@@ -51,9 +37,8 @@ static String moduleName(String moduleInfoFileContent) {
5137
boolean inComment = false;
5238
boolean moduleKeywordFound = false;
5339

54-
for(String line: moduleInfoFileContent.split("\n")) {
55-
String cleanedLine = line
56-
.replaceAll("/\\*.*\\*/", "") // open & close in this line
40+
for (String line : moduleInfoFileContent.split("\n")) {
41+
String cleanedLine = line.replaceAll("/\\*.*\\*/", "") // open & close in this line
5742
.replaceAll("//.*", ""); // line comment
5843
inComment = inComment || cleanedLine.contains("/*");
5944
cleanedLine = cleanedLine.replaceAll("/\\*.*", ""); // open in this line

src/main/java/org/gradlex/javamodule/testing/internal/ModuleInfoRequiresParser.java

Lines changed: 6 additions & 19 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.testing.internal;
183

194
import java.util.ArrayList;
@@ -26,7 +11,7 @@ public class ModuleInfoRequiresParser {
2611
public static List<String> parse(String moduleInfoFileContent, boolean runtimeOnly) {
2712
List<String> requires = new ArrayList<>();
2813
boolean insideComment = false;
29-
for(String line: moduleInfoFileContent.split("\n")) {
14+
for (String line : moduleInfoFileContent.split("\n")) {
3015
insideComment = parseLine(line, insideComment, requires, runtimeOnly);
3116
}
3217
return requires;
@@ -35,7 +20,8 @@ public static List<String> parse(String moduleInfoFileContent, boolean runtimeOn
3520
/**
3621
* @return true, if we are inside a multi-line comment after this line
3722
*/
38-
private static boolean parseLine(String moduleLine, boolean insideComment, List<String> requires, boolean runtimeOnly) {
23+
private static boolean parseLine(
24+
String moduleLine, boolean insideComment, List<String> requires, boolean runtimeOnly) {
3925
if (insideComment) {
4026
return !moduleLine.contains("*/");
4127
}
@@ -45,7 +31,8 @@ private static boolean parseLine(String moduleLine, boolean insideComment, List<
4531
.replace("{", "")
4632
.replace(RUNTIME_KEYWORD, "runtime")
4733
.replaceAll("/\\*.*?\\*/", " ")
48-
.trim().split("\\s+"));
34+
.trim()
35+
.split("\\s+"));
4936
int singleLineCommentStartIndex = tokens.indexOf("//");
5037
if (singleLineCommentStartIndex >= 0) {
5138
tokens = tokens.subList(0, singleLineCommentStartIndex);

src/main/java/org/gradlex/javamodule/testing/internal/actions/JavaCompileSetModulePathAction.java

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
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.testing.internal.actions;
183

4+
import java.util.ArrayList;
5+
import java.util.List;
6+
import javax.inject.Inject;
197
import org.gradle.api.Action;
208
import org.gradle.api.Describable;
219
import org.gradle.api.Task;
@@ -24,10 +12,6 @@
2412
import org.gradle.internal.jvm.JavaModuleDetector;
2513
import org.jspecify.annotations.NullMarked;
2614

27-
import javax.inject.Inject;
28-
import java.util.ArrayList;
29-
import java.util.List;
30-
3115
@NullMarked
3216
public abstract class JavaCompileSetModulePathAction implements Action<Task>, Describable {
3317

@@ -47,7 +31,9 @@ public void execute(Task task) {
4731

4832
// Since for Gradle this sources set does not look like a module, we have to define the module path ourselves
4933
compilerArgs.add("--module-path");
50-
compilerArgs.add(getJavaModuleDetector().inferModulePath(true, classpathAndModulePath).getAsPath());
34+
compilerArgs.add(getJavaModuleDetector()
35+
.inferModulePath(true, classpathAndModulePath)
36+
.getAsPath());
5137
javaCompile.setClasspath(getJavaModuleDetector().inferClasspath(true, classpathAndModulePath));
5238
javaCompile.getOptions().setCompilerArgs(compilerArgs);
5339
}

src/main/java/org/gradlex/javamodule/testing/internal/bridges/JavaModuleDependenciesBridge.java

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
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.testing.internal.bridges;
183

19-
import org.gradle.api.Project;
20-
import org.gradle.api.provider.Provider;
21-
import org.gradle.api.tasks.SourceSet;
22-
234
import java.lang.reflect.Method;
245
import java.util.Collections;
256
import java.util.List;
7+
import org.gradle.api.Project;
8+
import org.gradle.api.provider.Provider;
9+
import org.gradle.api.tasks.SourceSet;
2610

2711
public class JavaModuleDependenciesBridge {
2812

29-
public static Provider<?> create(Project project, String moduleName, SourceSet sourceSetWithModuleInfo) {
13+
public static Provider<?> create(Project project, String moduleName, SourceSet sourceSetWithModuleInfo) {
3014
Object javaModuleDependencies = project.getExtensions().findByName("javaModuleDependencies");
3115
if (javaModuleDependencies == null) {
3216
return null;
@@ -39,13 +23,16 @@ public static Provider<?> create(Project project, String moduleName, SourceSet s
3923
}
4024
}
4125

42-
public static void addRequiresRuntimeSupport(Project project, SourceSet sourceSetForModuleInfo, SourceSet sourceSetForClasspath) {
26+
public static void addRequiresRuntimeSupport(
27+
Project project, SourceSet sourceSetForModuleInfo, SourceSet sourceSetForClasspath) {
4328
Object javaModuleDependencies = project.getExtensions().findByName("javaModuleDependencies");
4429
if (javaModuleDependencies == null) {
4530
return;
4631
}
4732
try {
48-
Method addRequiresRuntimeSupport = javaModuleDependencies.getClass().getMethod("addRequiresRuntimeSupport", SourceSet.class, SourceSet.class);
33+
Method addRequiresRuntimeSupport = javaModuleDependencies
34+
.getClass()
35+
.getMethod("addRequiresRuntimeSupport", SourceSet.class, SourceSet.class);
4936
addRequiresRuntimeSupport.invoke(javaModuleDependencies, sourceSetForModuleInfo, sourceSetForClasspath);
5037
} catch (NoSuchMethodException e) {
5138
//noinspection UnnecessaryReturnStatement

src/main/java/org/gradlex/javamodule/testing/internal/provider/WhiteboxTestCompileArgumentProvider.java

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,16 @@
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.testing.internal.provider;
183

19-
import org.gradle.api.file.FileCollection;
20-
import org.gradle.api.model.ObjectFactory;
21-
import org.gradle.api.provider.ListProperty;
22-
import org.gradle.api.provider.Provider;
23-
import org.gradlex.javamodule.testing.internal.ModuleInfoParser;
24-
import org.gradle.api.tasks.compile.JavaCompile;
25-
import org.gradle.internal.jvm.JavaModuleDetector;
26-
import org.gradle.process.CommandLineArgumentProvider;
27-
284
import java.io.File;
295
import java.util.ArrayList;
306
import java.util.List;
317
import java.util.Set;
328
import java.util.stream.Collectors;
9+
import org.gradle.api.model.ObjectFactory;
10+
import org.gradle.api.provider.ListProperty;
11+
import org.gradle.api.provider.Provider;
12+
import org.gradle.process.CommandLineArgumentProvider;
13+
import org.gradlex.javamodule.testing.internal.ModuleInfoParser;
3314

3415
public class WhiteboxTestCompileArgumentProvider implements CommandLineArgumentProvider {
3516
private final Set<File> mainSourceFolders;
@@ -39,7 +20,10 @@ public class WhiteboxTestCompileArgumentProvider implements CommandLineArgumentP
3920
private final ListProperty<String> allTestRequires;
4021

4122
public WhiteboxTestCompileArgumentProvider(
42-
Set<File> mainSourceFolders, Set<File> testSourceFolders, ModuleInfoParser moduleInfoParser, ObjectFactory objects) {
23+
Set<File> mainSourceFolders,
24+
Set<File> testSourceFolders,
25+
ModuleInfoParser moduleInfoParser,
26+
ObjectFactory objects) {
4327
this.mainSourceFolders = mainSourceFolders;
4428
this.testSourceFolders = testSourceFolders;
4529
this.moduleInfoParser = moduleInfoParser;
@@ -57,8 +41,8 @@ public void testRequires(List<String> testRequires) {
5741
@Override
5842
public Iterable<String> asArguments() {
5943
String moduleName = moduleInfoParser.moduleName(mainSourceFolders);
60-
String testSources = testSourceFolders.stream().map(File::getPath)
61-
.collect(Collectors.joining(File.pathSeparator));
44+
String testSources =
45+
testSourceFolders.stream().map(File::getPath).collect(Collectors.joining(File.pathSeparator));
6246

6347
List<String> args = new ArrayList<>();
6448

0 commit comments

Comments
 (0)