-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add samples and test runner for samples
- Loading branch information
Showing
45 changed files
with
506 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Build Plugin | ||
on: [ push, pull_request ] | ||
jobs: | ||
gradle-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: git clone | ||
uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/[email protected] | ||
with: | ||
distribution: 'zulu' | ||
java-version: 11 | ||
- name: gradle build | ||
id: gradle | ||
uses: gradle/[email protected] | ||
with: | ||
arguments: :build |
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,16 @@ | ||
plugins { | ||
id("org.my.gradle.java-module") | ||
id("application") | ||
} | ||
|
||
application { | ||
applicationDefaultJvmArgs = listOf("-ea") | ||
mainClass.set("org.my.app.App") | ||
mainModule.set("org.my.app") | ||
} | ||
|
||
dependencies { | ||
javaModuleDependencies { | ||
runtimeOnly(gav("org.slf4j.simple")) | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
samples/use-all-java-module-plugins/app/src/integtest/java/module-info.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,4 @@ | ||
open module org.my.app.integtest { | ||
requires org.my.app; | ||
requires org.junit.jupiter.api; | ||
} |
24 changes: 24 additions & 0 deletions
24
...use-all-java-module-plugins/app/src/integtest/java/org/my/app/integtest/AppIntegTest.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,24 @@ | ||
package org.my.app.integtest; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.my.app.App; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class AppIntegTest { | ||
|
||
@Test | ||
public void appDoesNotExplode() throws IOException { | ||
assertTrue(App.doWork()); | ||
|
||
try (InputStream is = AppIntegTest.class.getResourceAsStream("AppTestData.txt")) { | ||
System.out.println(new BufferedReader(new InputStreamReader(is)).readLine()); | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...-all-java-module-plugins/app/src/integtest/resources/org/my/app/integtest/AppTestData.txt
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 @@ | ||
This is balackbox test data |
7 changes: 7 additions & 0 deletions
7
samples/use-all-java-module-plugins/app/src/main/java/module-info.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,7 @@ | ||
module org.my.app { | ||
requires org.slf4j; | ||
requires org.my.lib; | ||
requires org.apache.xmlbeans; | ||
|
||
exports org.my.app; | ||
} |
33 changes: 33 additions & 0 deletions
33
samples/use-all-java-module-plugins/app/src/main/java/org/my/app/App.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,33 @@ | ||
package org.my.app; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.slf4j.spi.LoggerFactoryBinder; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
|
||
public class App { | ||
public static void main(String[] args) throws IOException { | ||
doWork(); | ||
} | ||
|
||
public static boolean doWork() throws IOException { | ||
ObjectMapper om = new ObjectMapper(); | ||
if (!om.canSerialize(LoggerFactoryBinder.class)) { | ||
throw new RuntimeException("Boom!"); | ||
} | ||
System.out.println(App.class.getModule().getName()); | ||
|
||
printData(); | ||
|
||
return true; | ||
} | ||
|
||
protected static void printData() throws IOException { | ||
try (InputStream is = App.class.getResourceAsStream("AppData.txt")) { | ||
System.out.println(new BufferedReader(new InputStreamReader(is)).readLine()); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
samples/use-all-java-module-plugins/app/src/main/resources/org/my/app/AppData.txt
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 @@ | ||
This is data |
24 changes: 24 additions & 0 deletions
24
samples/use-all-java-module-plugins/app/src/test/java/org/my/app/AppWhiteboxTest.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,24 @@ | ||
package org.my.app; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class AppWhiteboxTest { | ||
|
||
@Test | ||
public void printDataTest() throws IOException { | ||
App.printData(); | ||
assertEquals("org.my.app", AppWhiteboxTest.class.getModule().getName()); | ||
|
||
try (InputStream is = AppWhiteboxTest.class.getResourceAsStream("AppTestData.txt")) { | ||
System.out.println(new BufferedReader(new InputStreamReader(is)).readLine()); | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
samples/use-all-java-module-plugins/app/src/test/resources/org/my/app/AppTestData.txt
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 @@ | ||
This is whitebox test data |
9 changes: 9 additions & 0 deletions
9
samples/use-all-java-module-plugins/build-logic/build.gradle.kts
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,9 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
dependencies { | ||
implementation("de.jjohannes.gradle:extra-java-module-info:0.12") | ||
implementation("de.jjohannes.gradle:java-module-dependencies:0.7") | ||
implementation("de.jjohannes.gradle:java-module-testing:0.1") | ||
} |
7 changes: 7 additions & 0 deletions
7
samples/use-all-java-module-plugins/build-logic/settings.gradle.kts
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,7 @@ | ||
dependencyResolutionManagement { | ||
repositories.gradlePluginPortal() | ||
} | ||
|
||
// This is for testing against the latest version of the plugin, remove if you copied this for a real project | ||
includeBuild(extra.properties["pluginLocation"] ?: rootDir.parentFile.parentFile.parent) | ||
|
10 changes: 10 additions & 0 deletions
10
...les/use-all-java-module-plugins/build-logic/src/main/kotlin/org.my.gradle.base.gradle.kts
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,10 @@ | ||
plugins { | ||
id("de.jjohannes.extra-java-module-info") | ||
id("de.jjohannes.java-module-dependencies") | ||
} | ||
|
||
group = "org.my" | ||
|
||
extraJavaModuleInfo { | ||
automaticModule("org.apache.commons:commons-math3", "commons.math3") | ||
} |
35 changes: 35 additions & 0 deletions
35
...-all-java-module-plugins/build-logic/src/main/kotlin/org.my.gradle.java-module.gradle.kts
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,35 @@ | ||
plugins { | ||
id("java") | ||
id("org.my.gradle.base") | ||
id("de.jjohannes.java-module-testing") | ||
} | ||
|
||
javaModuleTesting.whitebox( | ||
testing.suites.getByName<JvmTestSuite>("test") { | ||
useJUnitJupiter("") | ||
targets.all { | ||
testTask { jvmArgs("-Dorg.slf4j.simpleLogger.defaultLogLevel=error") } | ||
} | ||
} | ||
) { | ||
requires.add("org.junit.jupiter.api") | ||
opensTo.add("org.junit.platform.commons") | ||
} | ||
|
||
javaModuleTesting.blackbox( | ||
testing.suites.create<JvmTestSuite>("integtest") { | ||
useJUnitJupiter("") | ||
testType.set("blackbox") | ||
dependencies { | ||
implementation(project.dependencies.platform(project(":platform"))) | ||
} | ||
targets.all { | ||
testTask { jvmArgs("-Dorg.slf4j.simpleLogger.defaultLogLevel=error") } | ||
} | ||
tasks.check { dependsOn(targets) } | ||
} | ||
) | ||
|
||
dependencies { | ||
implementation(platform(project(":platform"))) | ||
} |
6 changes: 6 additions & 0 deletions
6
...use-all-java-module-plugins/build-logic/src/main/kotlin/org.my.gradle.platform.gradle.kts
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,6 @@ | ||
plugins { | ||
id("java-platform") | ||
id("org.my.gradle.base") | ||
} | ||
|
||
javaPlatform.allowDependencies() // Use existing Platforms/BOMs |
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,3 @@ | ||
> Task :app:run | ||
org.my.app | ||
This is data |
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,2 @@ | ||
executable: gradlew | ||
expected-output-file: build.out |
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,4 @@ | ||
plugins { | ||
id("org.my.gradle.java-module") | ||
id("java-library") | ||
} |
4 changes: 4 additions & 0 deletions
4
samples/use-all-java-module-plugins/lib/src/integtest/java/module-info.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,4 @@ | ||
open module org.my.lib.integtest { | ||
requires org.my.lib; | ||
requires org.junit.jupiter.api; | ||
} |
10 changes: 10 additions & 0 deletions
10
samples/use-all-java-module-plugins/lib/src/main/java/module-info.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,10 @@ | ||
module org.my.lib { | ||
requires transitive com.fasterxml.jackson.databind; | ||
|
||
// Patched to be a module | ||
requires commons.math3; | ||
|
||
// JDK modules | ||
requires java.logging; | ||
requires jdk.charsets; | ||
} |
18 changes: 18 additions & 0 deletions
18
samples/use-all-java-module-plugins/platform/build.gradle.kts
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,18 @@ | ||
plugins { | ||
id("org.my.gradle.platform") | ||
} | ||
|
||
|
||
dependencies { | ||
api(platform("com.fasterxml.jackson:jackson-bom:2.13.2")) | ||
api(platform("org.junit:junit-bom:5.7.2")) | ||
} | ||
|
||
dependencies.constraints { | ||
javaModuleDependencies { | ||
api(gav("commons.math3", "3.6.1")) | ||
api(gav("org.apache.xmlbeans", "5.0.1")) | ||
api(gav("org.slf4j", "1.7.28")) | ||
api(gav("org.slf4j.simple", "1.7.28")) | ||
} | ||
} |
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,9 @@ | ||
pluginManagement { | ||
includeBuild("build-logic") | ||
} | ||
dependencyResolutionManagement { | ||
repositories.mavenCentral() | ||
} | ||
|
||
include("app", "lib") | ||
include("platform") |
20 changes: 20 additions & 0 deletions
20
samples/use-only-java-module-testing-plugin/app/build.gradle.kts
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,20 @@ | ||
plugins { | ||
id("org.my.gradle.java-module") | ||
id("application") | ||
} | ||
|
||
application { | ||
applicationDefaultJvmArgs = listOf("-ea") | ||
mainClass.set("org.my.app.App") | ||
mainModule.set("org.my.app") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":lib")) | ||
implementation("org.apache.xmlbeans:xmlbeans") | ||
implementation("org.slf4j:slf4j-api") | ||
|
||
integtestImplementation(project(path)) | ||
|
||
runtimeOnly("org.slf4j:slf4j-simple") | ||
} |
4 changes: 4 additions & 0 deletions
4
samples/use-only-java-module-testing-plugin/app/src/integtest/java/module-info.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,4 @@ | ||
open module org.my.app.integtest { | ||
requires org.my.app; | ||
requires org.junit.jupiter.api; | ||
} |
24 changes: 24 additions & 0 deletions
24
...-java-module-testing-plugin/app/src/integtest/java/org/my/app/integtest/AppIntegTest.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,24 @@ | ||
package org.my.app.integtest; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.my.app.App; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class AppIntegTest { | ||
|
||
@Test | ||
public void appDoesNotExplode() throws IOException { | ||
assertTrue(App.doWork()); | ||
|
||
try (InputStream is = AppIntegTest.class.getResourceAsStream("AppTestData.txt")) { | ||
System.out.println(new BufferedReader(new InputStreamReader(is)).readLine()); | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...va-module-testing-plugin/app/src/integtest/resources/org/my/app/integtest/AppTestData.txt
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 @@ | ||
This is balackbox test data |
7 changes: 7 additions & 0 deletions
7
samples/use-only-java-module-testing-plugin/app/src/main/java/module-info.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,7 @@ | ||
module org.my.app { | ||
requires org.slf4j; | ||
requires org.my.lib; | ||
requires org.apache.xmlbeans; | ||
|
||
exports org.my.app; | ||
} |
32 changes: 32 additions & 0 deletions
32
samples/use-only-java-module-testing-plugin/app/src/main/java/org/my/app/App.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,32 @@ | ||
package org.my.app; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.slf4j.spi.LoggerFactoryBinder; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
|
||
public class App { | ||
public static void main(String[] args) throws IOException { | ||
doWork(); | ||
} | ||
|
||
public static boolean doWork() throws IOException { | ||
ObjectMapper om = new ObjectMapper(); | ||
if (!om.canSerialize(LoggerFactoryBinder.class)) { | ||
throw new RuntimeException("Boom!"); | ||
} | ||
System.out.println(App.class.getModule().getName()); | ||
printData(); | ||
|
||
return true; | ||
} | ||
|
||
protected static void printData() throws IOException { | ||
try (InputStream is = App.class.getResourceAsStream("AppData.txt")) { | ||
System.out.println(new BufferedReader(new InputStreamReader(is)).readLine()); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
samples/use-only-java-module-testing-plugin/app/src/main/resources/org/my/app/AppData.txt
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 @@ | ||
This is data |
Oops, something went wrong.