forked from java9-modularity/gradle-modules-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
java9-modularity#72: initial refactorings/improvements
necessary for further commits MAIN: 1) renamed TestModuleOptions.isRunOnClasspath() to getRunOnClasspath() (otherwise won't work with Kotlin DSL) + added a Kotlin DSL example for "runOnClasspath = true" to README.md 2) introduced JavaProjectHelper and applied it to CompileTask 3) added comments for all anonymous classes that should not be removed 4) minor improvements in ModuleSystemPlugin 5) minor fixes in test-project-kotlin/README.md TEST: 1) bumped smoke-test Gradle version to 5.0 (for improved Kotlin DSL) 2) introduced a no-op "moduleOptions" access in greeter.api (for testing DSL) 3) introduced SmokeTestHelper for ModulePluginSmokeTest 4) disabled stackTraceFilters in all tests 5) updated Kotlin to 1.3.20
- Loading branch information
1 parent
ca86e2d
commit 86e65c4
Showing
21 changed files
with
298 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ test { | |
|
||
testLogging { | ||
events 'PASSED', 'FAILED', 'SKIPPED' | ||
stackTraceFilters = [] | ||
} | ||
} | ||
|
||
|
63 changes: 63 additions & 0 deletions
63
src/main/java/org/javamodularity/moduleplugin/JavaProjectHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.javamodularity.moduleplugin; | ||
|
||
import org.gradle.api.Project; | ||
import org.gradle.api.Task; | ||
import org.gradle.api.plugins.JavaPlugin; | ||
import org.gradle.api.tasks.SourceSet; | ||
import org.gradle.api.tasks.SourceSetContainer; | ||
import org.gradle.api.tasks.compile.JavaCompile; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Generic helper for Gradle {@link Project} API that has {@link JavaPlugin} applied. | ||
*/ | ||
public final class JavaProjectHelper { | ||
|
||
private final Project project; | ||
|
||
public JavaProjectHelper(Project project) { | ||
this.project = project; | ||
} | ||
|
||
public Project project() { | ||
return project; | ||
} | ||
|
||
//region SOURCE SETS | ||
public SourceSetContainer sourceSets() { | ||
return project.getExtensions().getByType(SourceSetContainer.class); | ||
} | ||
|
||
public SourceSet sourceSet(String sourceSetName) { | ||
return sourceSets().getByName(sourceSetName); | ||
} | ||
|
||
public SourceSet mainSourceSet() { | ||
return sourceSet(SourceSet.MAIN_SOURCE_SET_NAME); | ||
} | ||
|
||
public SourceSet testSourceSet(String sourceSetName) { | ||
return sourceSet(SourceSet.TEST_SOURCE_SET_NAME); | ||
} | ||
//endregion | ||
|
||
//region TASKS | ||
public Task task(String taskName) { | ||
return project.getTasks().getByName(taskName); | ||
} | ||
|
||
public JavaCompile compileJavaTask(String taskName) { | ||
return (JavaCompile) task(taskName); | ||
} | ||
|
||
public Optional<Task> findTask(String taskName) { | ||
return Optional.ofNullable(project.getTasks().findByName(taskName)); | ||
} | ||
|
||
public Optional<JavaCompile> findCompileJavaTask(String taskName) { | ||
return findTask(taskName).map(JavaCompile.class::cast); | ||
} | ||
//endregion | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.