-
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.
build: add 'feature.legacy-classpath' plugin (#85)
Signed-off-by: Jendrik Johannes <jendrik.johannes@gmail.com>
- Loading branch information
Showing
5 changed files
with
80 additions
and
2 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
1 change: 1 addition & 0 deletions
1
src/main/descriptions/org.hiero.gradle.feature.legacy-classpath.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 @@ | ||
Conventions to allow non-module Jars on the classpath if a framework is used that is not yet JPMS compatible (e.g. has split packages) |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/org.hiero.gradle.feature.legacy-classpath.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,11 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
plugins { id("org.hiero.gradle.base.jpms-modules") } | ||
|
||
// Make sure 'org.gradlex.java-module-dependencies' is applied as the auto-apply through settings | ||
// may not happen in a non-module project | ||
apply(plugin = "org.gradlex.java-module-dependencies") | ||
|
||
extraJavaModuleInfo { | ||
failOnMissingModuleInfo = false | ||
failOnAutomaticModules = false | ||
} |
65 changes: 65 additions & 0 deletions
65
src/test/kotlin/org/hiero/gradle/test/LegacyClasspathTest.kt
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,65 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.hiero.gradle.test | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.gradle.testkit.runner.TaskOutcome | ||
import org.hiero.gradle.test.fixtures.GradleProject | ||
import org.junit.jupiter.api.Test | ||
|
||
class LegacyClasspathTest { | ||
|
||
@Test | ||
fun `can build a classpath-based application`() { | ||
val p = GradleProject().withMinimalStructure() | ||
p.moduleInfo.delete() | ||
// explicitly register Module without module-info | ||
p.settingsFile.appendText("""javaModules { module("product/module-a") }""") | ||
p.dependencyVersionsFile( | ||
""" | ||
plugins { | ||
id("org.hiero.gradle.base.lifecycle") | ||
id("org.hiero.gradle.base.jpms-modules") | ||
} | ||
dependencies { api(platform("com.google.cloud:libraries-bom:26.49.0")) } | ||
""" | ||
.trimIndent() | ||
) | ||
p.aggregationBuildFile( | ||
""" | ||
plugins { id("java") } | ||
dependencies { implementation(project(":module-a")) } | ||
""" | ||
.trimIndent() | ||
) | ||
p.file( | ||
"gradle/modules.properties", | ||
""" | ||
# Jars that are not yet modules | ||
com.google.api.gax=com.google.api:gax | ||
com.google.auth.oauth2=com.google.auth:google-auth-library-oauth2-http | ||
com.google.cloud.core=com.google.cloud:google-cloud-core | ||
com.google.cloud.storage=com.google.cloud:google-cloud-storage | ||
""" | ||
.trimIndent() | ||
) | ||
p.moduleBuildFile( | ||
""" | ||
plugins { | ||
id("org.hiero.gradle.module.application") | ||
id("org.hiero.gradle.feature.legacy-classpath") | ||
} | ||
mainModuleInfo { | ||
requires("com.google.api.gax") | ||
requires("com.google.auth.oauth2") | ||
requires("com.google.cloud.core") | ||
requires("com.google.cloud.storage") | ||
} | ||
""" | ||
.trimIndent() | ||
) | ||
|
||
val result = p.run("assemble") | ||
|
||
assertThat(result.task(":module-a:assemble")?.outcome).isEqualTo(TaskOutcome.SUCCESS) | ||
} | ||
} |
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