-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
568 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,24 @@ | ||
plugins { | ||
id("org.example.java-module-app") | ||
} | ||
|
||
application { | ||
applicationDefaultJvmArgs = listOf("-ea") | ||
mainClass.set("org.example.app.App") | ||
mainModule.set("org.example.app") | ||
} | ||
|
||
mainModuleInfo { | ||
runtimeOnly("org.slf4j.simple") | ||
} | ||
|
||
testModuleInfo { | ||
requires("org.junit.jupiter.api") | ||
} | ||
|
||
moduleInfo { | ||
version("org.slf4j", "2.0.7") | ||
version("org.slf4j.simple", "2.0.7") | ||
version("com.fasterxml.jackson.databind", "2.14.0") | ||
version("org.junit.jupiter.api", "5.9.3") | ||
} |
6 changes: 6 additions & 0 deletions
6
samples/module-info-dsl-no-platform/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,6 @@ | ||
module org.example.app { | ||
requires org.example.lib; | ||
requires org.slf4j; | ||
|
||
exports org.example.app; | ||
} |
16 changes: 16 additions & 0 deletions
16
samples/module-info-dsl-no-platform/app/src/main/java/org/example/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,16 @@ | ||
package org.example.app; | ||
|
||
import org.example.lib.Lib; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class App { | ||
|
||
public static void main(String[] args) { | ||
LoggerFactory.getLogger(App.class).info("App running..."); | ||
doWork(); | ||
} | ||
|
||
public static void doWork() { | ||
new Lib(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
samples/module-info-dsl-no-platform/app/src/test/java/org/example/app/AppTest.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,26 @@ | ||
package org.example.app; | ||
|
||
import org.example.lib.Lib; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class AppTest { | ||
|
||
@Test | ||
public void testApp() throws IOException { | ||
assertEquals("org.example.lib", Lib.class.getModule().getName()); | ||
assertEquals("org.example.app", App.class.getModule().getName()); | ||
assertEquals("org.example.app", AppTest.class.getModule().getName()); | ||
try (InputStream is = AppTest.class.getResourceAsStream("/data.txt")) { | ||
assertNotNull(is); | ||
assertEquals("ABC", new String(is.readAllBytes(), UTF_8)); | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
samples/module-info-dsl-no-platform/app/src/test/resources/data.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 @@ | ||
ABC |
4 changes: 4 additions & 0 deletions
4
samples/module-info-dsl-no-platform/app/src/testFunctional/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.example.app.test.functional { | ||
requires org.example.app; | ||
requires org.junit.jupiter.api; | ||
} |
25 changes: 25 additions & 0 deletions
25
...o-dsl-no-platform/app/src/testFunctional/java/org/example/app/test/AppFunctionalTest.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,25 @@ | ||
package org.example.app.test; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.example.app.App; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class AppFunctionalTest { | ||
|
||
@Test | ||
void testAppFunctional() throws IOException { | ||
assertEquals("org.example.app", App.class.getModule().getName()); | ||
assertEquals("org.example.app.test.functional", AppFunctionalTest.class.getModule().getName()); | ||
try (InputStream is = AppFunctionalTest.class.getResourceAsStream("/data.txt")) { | ||
assertNotNull(is); | ||
assertEquals("DEF", new String(is.readAllBytes(), UTF_8)); | ||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
samples/module-info-dsl-no-platform/app/src/testFunctional/resources/data.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 @@ | ||
DEF |
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 @@ | ||
plugins { | ||
id("org.example.root") | ||
} |
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,38 @@ | ||
> Task :lib:compileJava | ||
> Task :lib:processResources NO-SOURCE | ||
> Task :lib:classes | ||
> Task :lib:jar | ||
> Task :app:compileJava | ||
> Task :app:processResources NO-SOURCE | ||
> Task :app:classes | ||
> Task :app:jar | ||
> Task :app:startScripts | ||
> Task :app:distTar | ||
> Task :app:distZip | ||
> Task :app:assemble | ||
> Task :app:compileTestJava | ||
> Task :app:processTestResources | ||
> Task :app:testClasses | ||
> Task :app:test | ||
> Task :app:compileTestFunctionalJava | ||
> Task :app:processTestFunctionalResources | ||
> Task :app:testFunctionalClasses | ||
> Task :app:testFunctionalJar | ||
> Task :app:testFunctional | ||
> Task :app:check | ||
> Task :app:build | ||
> Task :lib:assemble | ||
> Task :lib:compileTestJava | ||
> Task :lib:processTestResources | ||
> Task :lib:testClasses | ||
> Task :lib:test | ||
> Task :lib:compileTestFunctionalJava | ||
> Task :lib:processTestFunctionalResources | ||
> Task :lib:testFunctionalClasses | ||
> Task :lib:testFunctionalJar | ||
> Task :lib:testFunctional | ||
> Task :lib:check | ||
> Task :lib:build | ||
|
||
> Task :app:run | ||
[main] INFO org.example.app.App - App running... |
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 |
9 changes: 9 additions & 0 deletions
9
samples/module-info-dsl-no-platform/gradle/plugins/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("com.autonomousapps:dependency-analysis-gradle-plugin:1.20.0") | ||
implementation("org.gradlex:java-module-dependencies:1.3.1") | ||
implementation("org.gradlex:java-module-testing:1.2") | ||
} |
6 changes: 6 additions & 0 deletions
6
samples/module-info-dsl-no-platform/gradle/plugins/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,6 @@ | ||
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.parentFile.parent) |
19 changes: 19 additions & 0 deletions
19
...dule-info-dsl-no-platform/gradle/plugins/src/main/kotlin/org.example.java-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,19 @@ | ||
plugins { | ||
id("java") | ||
id("org.gradlex.java-module-dependencies") | ||
id("org.gradlex.java-module-testing") | ||
} | ||
|
||
group = "org.example" | ||
|
||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17)) | ||
testing.suites.register<JvmTestSuite>("testFunctional") | ||
tasks.check { dependsOn(tasks.named("testFunctional")) } | ||
|
||
javaModuleDependencies { | ||
versionsFromPlatformAndConsistentResolution(":app", ":app") | ||
} | ||
|
||
tasks.withType<Test>().configureEach { | ||
jvmArgs("-Dorg.slf4j.simpleLogger.defaultLogLevel=error") | ||
} |
5 changes: 5 additions & 0 deletions
5
...nfo-dsl-no-platform/gradle/plugins/src/main/kotlin/org.example.java-module-app.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,5 @@ | ||
plugins { | ||
id("org.example.java-base") | ||
id("application") | ||
id("org.gradlex.java-module-versions") | ||
} |
5 changes: 5 additions & 0 deletions
5
...le-info-dsl-no-platform/gradle/plugins/src/main/kotlin/org.example.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,5 @@ | ||
plugins { | ||
id("org.example.java-base") | ||
id("java-library") | ||
} | ||
|
3 changes: 3 additions & 0 deletions
3
...es/module-info-dsl-no-platform/gradle/plugins/src/main/kotlin/org.example.root.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,3 @@ | ||
plugins { | ||
id("com.autonomousapps.dependency-analysis") | ||
} |
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 @@ | ||
plugins { | ||
id("org.example.java-module") | ||
} | ||
|
||
testModuleInfo { | ||
requires("org.junit.jupiter.api") | ||
} |
7 changes: 7 additions & 0 deletions
7
samples/module-info-dsl-no-platform/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,7 @@ | ||
module org.example.lib { | ||
requires transitive com.fasterxml.jackson.databind; | ||
|
||
requires java.logging; // JDK module | ||
|
||
exports org.example.lib; | ||
} |
10 changes: 10 additions & 0 deletions
10
samples/module-info-dsl-no-platform/lib/src/main/java/org/example/lib/Lib.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 @@ | ||
package org.example.lib; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
public class Lib { | ||
|
||
public void process(ObjectMapper mapper) { | ||
|
||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
samples/module-info-dsl-no-platform/lib/src/test/java/org/example/lib/LibTest.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,23 @@ | ||
package org.example.lib; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
class LibTest { | ||
|
||
@Test | ||
void testLib() throws IOException { | ||
assertEquals("org.example.lib", Lib.class.getModule().getName()); | ||
assertEquals("org.example.lib", LibTest.class.getModule().getName()); | ||
try (InputStream is = LibTest.class.getResourceAsStream("/data.txt")) { | ||
assertNotNull(is); | ||
assertEquals("2*21", new String(is.readAllBytes(), UTF_8)); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
samples/module-info-dsl-no-platform/lib/src/test/resources/data.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 @@ | ||
2*21 |
4 changes: 4 additions & 0 deletions
4
samples/module-info-dsl-no-platform/lib/src/testFunctional/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.example.lib.test.functional { | ||
requires org.example.lib; | ||
requires org.junit.jupiter.api; | ||
} |
24 changes: 24 additions & 0 deletions
24
...o-dsl-no-platform/lib/src/testFunctional/java/org/example/lib/test/LibFunctionalTest.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.example.lib.test; | ||
|
||
import org.example.lib.Lib; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
class LibFunctionalTest { | ||
|
||
@Test | ||
void testLibFunctional() throws IOException { | ||
assertEquals("org.example.lib", Lib.class.getModule().getName()); | ||
assertEquals("org.example.lib.test.functional", LibFunctionalTest.class.getModule().getName()); | ||
try (InputStream is = LibFunctionalTest.class.getResourceAsStream("/data.txt")) { | ||
assertNotNull(is); | ||
assertEquals("42", new String(is.readAllBytes(), UTF_8)); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
samples/module-info-dsl-no-platform/lib/src/testFunctional/resources/data.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 @@ | ||
42 |
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,8 @@ | ||
pluginManagement { | ||
includeBuild("gradle/plugins") | ||
} | ||
dependencyResolutionManagement { | ||
repositories.mavenCentral() | ||
} | ||
|
||
include("app", "lib") |
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,17 @@ | ||
plugins { | ||
id("org.example.java-module-app") | ||
} | ||
|
||
application { | ||
applicationDefaultJvmArgs = listOf("-ea") | ||
mainClass.set("org.example.app.App") | ||
mainModule.set("org.example.app") | ||
} | ||
|
||
mainModuleInfo { | ||
runtimeOnly("org.slf4j.simple") | ||
} | ||
|
||
testModuleInfo { | ||
requires("org.junit.jupiter.api") | ||
} |
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 @@ | ||
module org.example.app { | ||
requires org.example.lib; | ||
requires org.slf4j; | ||
|
||
exports org.example.app; | ||
} |
16 changes: 16 additions & 0 deletions
16
samples/module-info-dsl/app/src/main/java/org/example/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,16 @@ | ||
package org.example.app; | ||
|
||
import org.example.lib.Lib; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class App { | ||
|
||
public static void main(String[] args) { | ||
LoggerFactory.getLogger(App.class).info("App running..."); | ||
doWork(); | ||
} | ||
|
||
public static void doWork() { | ||
new Lib(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
samples/module-info-dsl/app/src/test/java/org/example/app/AppTest.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,26 @@ | ||
package org.example.app; | ||
|
||
import org.example.lib.Lib; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class AppTest { | ||
|
||
@Test | ||
public void testApp() throws IOException { | ||
assertEquals("org.example.lib", Lib.class.getModule().getName()); | ||
assertEquals("org.example.app", App.class.getModule().getName()); | ||
assertEquals("org.example.app", AppTest.class.getModule().getName()); | ||
try (InputStream is = AppTest.class.getResourceAsStream("/data.txt")) { | ||
assertNotNull(is); | ||
assertEquals("ABC", new String(is.readAllBytes(), UTF_8)); | ||
} | ||
} | ||
|
||
} |
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 @@ | ||
ABC |
4 changes: 4 additions & 0 deletions
4
samples/module-info-dsl/app/src/testFunctional/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.example.app.test.functional { | ||
requires org.example.app; | ||
requires org.junit.jupiter.api; | ||
} |
Oops, something went wrong.