-
Notifications
You must be signed in to change notification settings - Fork 6
enhancement/bento-35: Use Gradle convention script plugins. #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
097bd48
BENTO-35: Use Gradle convention script plugins.
1026a97
BENTO-35:
e895f1c
BENTO-13:
d006605
BENTO-35:
31dd85d
BENTO-35:
9c0dd84
BENTO-35:
4e60338
BENTO-35:
e19aa05
BENTO-35:
06c7dca
BENTO-35:
d2cf07f
Revert "BENTO-35:"
76ec900
BENTO-35: Minor build script formatting
Col-E File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 'groovy-gradle-plugin' | ||
| } | ||
|
|
||
| description = | ||
| 'Used to apply plugins to projects and to configure dependencies and tasks. Runs during project ' + | ||
| 'configuration, after settings.' | ||
|
|
||
| dependencies { | ||
| implementation gradleApi() | ||
| implementation localGroovy() | ||
|
|
||
| implementation libs.benmanes.versions.gradlePlugin.dependency | ||
| implementation libs.javafx.gradlePlugin.dependency | ||
| implementation libs.jreleaser.gradlePlugin.dependency | ||
| } |
This file contains hidden or 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 @@ | ||
| org.gradle.caching=true | ||
| org.gradle.jvmargs=-Xmx2500m -Dfile.encoding=UTF-8 |
This file contains hidden or 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 @@ | ||
| pluginManagement { | ||
| repositories { | ||
| gradlePluginPortal() | ||
| mavenCentral() | ||
| } | ||
| } | ||
|
|
||
| dependencyResolutionManagement { | ||
| repositories { | ||
| gradlePluginPortal() | ||
| mavenCentral() | ||
| } | ||
| versionCatalogs { | ||
| libs { | ||
| from(files('../gradle/libs.versions.toml')) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| rootProject.name = 'build-logic' |
6 changes: 6 additions & 0 deletions
6
build-logic/src/main/groovy/bento.project.build-lifecycle.gradle
|
Col-E marked this conversation as resolved.
|
This file contains hidden or 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 @@ | ||
| import static software.coley.gradle.lifecycle.BuildLifecycle.ALL_CLASSES_TASK_NAME | ||
|
|
||
| tasks.register(ALL_CLASSES_TASK_NAME) { | ||
| description = 'Compiles all main and test code for all applicable subprojects and test suites.' | ||
| group = LifecycleBasePlugin.BUILD_GROUP | ||
| } |
120 changes: 120 additions & 0 deletions
120
build-logic/src/main/groovy/bento.project.project-convention.gradle
|
Col-E marked this conversation as resolved.
|
This file contains hidden or 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,120 @@ | ||
| import org.gradle.api.plugins.jvm.JvmTestSuite | ||
| import org.gradlex.jvm.dependency.conflict.detection.rules.CapabilityDefinition.* | ||
| import software.coley.gradle.artifacts.TestFxAlignmentRule | ||
| import software.coley.gradle.task.extensions.BentoConventionExtension | ||
|
|
||
| import static software.coley.gradle.lifecycle.BuildLifecycle.ALL_CLASSES_TASK_NAME | ||
|
|
||
| plugins { | ||
| id 'java-library' | ||
| id 'com.github.ben-manes.versions' | ||
| id 'bento.project.build-lifecycle' | ||
| id 'bento.test.unit-test-suite' | ||
| } | ||
|
|
||
| def versionCatalog = versionCatalogs.named('libs') | ||
|
|
||
| group = 'software.coley.bento-fx' | ||
| version = versionCatalog.findVersion("bentofx").get().requiredVersion | ||
|
|
||
| def normalizedProjectName = providers.provider { | ||
| project.path.substring(1).replace(':', '.') | ||
| } | ||
|
|
||
| extensions.create('bentoConvention', BentoConventionExtension, normalizedProjectName) | ||
|
|
||
| // Get the Java JDK version specified in libs.versions.toml and accommodate all | ||
| // the different ways Gradle and its plugins take the Java version... | ||
| def jdkVersion = versionCatalog.findVersion("java-jdk").get().requiredVersion | ||
| def javaLanguageVersion = JavaLanguageVersion.of(jdkVersion) | ||
| def javaMajorVersionAsInt = javaLanguageVersion.asInt() | ||
|
|
||
| dependencies { | ||
|
|
||
| components.all(TestFxAlignmentRule) | ||
|
|
||
| api platform(project(':platform')) | ||
| } | ||
|
|
||
| java { | ||
| toolchain { | ||
| languageVersion = JavaLanguageVersion.of(javaMajorVersionAsInt) | ||
| } | ||
|
Col-E marked this conversation as resolved.
|
||
|
|
||
| withSourcesJar() | ||
| withJavadocJar() | ||
| } | ||
|
|
||
| javadoc { | ||
| options { | ||
| addStringOption('Xdoclint:none', '-quiet') | ||
| } | ||
| } | ||
|
|
||
| testing { | ||
| suites { | ||
| configureEach { suite -> | ||
| if (suite instanceof JvmTestSuite) { | ||
|
|
||
| def junitVersion = | ||
| versionCatalog.findVersion('junit').get().requiredVersion | ||
|
|
||
| useJUnitJupiter(junitVersion) | ||
|
|
||
| targets.configureEach { | ||
| testTask.configure { | ||
| it.filter { | ||
| includeTestsMatching '*Test' | ||
| includeTestsMatching '*Test\$*' | ||
| failOnNoDiscoveredTests = false | ||
| } | ||
|
|
||
| // Set system properties for the test JVM(s) | ||
| systemProperty 'project.name', rootProject.name | ||
| // Turns out we really DO need a graphics environment | ||
| // to initialize the JavaFx platform used by some | ||
| // JUnit tests. Therefore, we can NOT run JUnit | ||
| // tests headless. | ||
| systemProperty 'java.awt.headless', 'false' | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| tasks.named(ALL_CLASSES_TASK_NAME) { | ||
| dependsOn(tasks.named('classes')) | ||
| } | ||
|
|
||
| tasks.withType(JavaCompile).configureEach { | ||
| it.options.with { | ||
| encoding = 'UTF-8' | ||
| release = javaMajorVersionAsInt | ||
| fork = true | ||
| forkOptions.memoryMaximumSize = '1g' | ||
| options.compilerArgs << '-parameters' | ||
| } | ||
| } | ||
|
|
||
| tasks.withType(Jar).configureEach { | ||
| archiveBaseName = normalizedProjectName | ||
|
|
||
| from(project.isolated.rootProject.projectDirectory) { | ||
| include 'LICENSE' | ||
| into 'META-INF' | ||
| rename { 'LICENSE.txt' } | ||
| } | ||
| } | ||
|
|
||
| tasks.withType(JavaExec).configureEach { | ||
| javaLauncher = javaToolchains.launcherFor { | ||
| languageVersion = javaLanguageVersion | ||
| } | ||
| } | ||
|
|
||
| tasks.withType(Test).configureEach { | ||
| javaLauncher = javaToolchains.launcherFor { | ||
| languageVersion = javaLanguageVersion | ||
| } | ||
| } | ||
51 changes: 51 additions & 0 deletions
51
build-logic/src/main/groovy/bento.release.publish-convention.gradle
|
Col-E marked this conversation as resolved.
|
This file contains hidden or 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,51 @@ | ||
| plugins { | ||
| id 'java' | ||
| id 'bento.project.project-convention' | ||
| id 'maven-publish' | ||
| } | ||
|
|
||
| def bentoConvention = extensions.getByName('bentoConvention') | ||
|
|
||
| publishing { | ||
| publications { | ||
| mavenJava(MavenPublication) { | ||
| artifactId = bentoConvention.normalizedProjectName.get() | ||
|
|
||
| from components['java'] | ||
|
|
||
| pom { | ||
| url.set( 'https://github.com/Col-E/BentoFX') | ||
| inceptionYear.set( '2025') | ||
|
|
||
| licenses { | ||
| license { | ||
| name.set( 'MIT') | ||
| url.set( 'https://spdx.org/licenses/MIT.html') | ||
| } | ||
| } | ||
| developers { | ||
| developer { | ||
| id = 'Col-E' | ||
| name = 'Matt Coley' | ||
| } | ||
|
Col-E marked this conversation as resolved.
|
||
| developer { | ||
| id.set( 'philliplbryant') | ||
| name.set( 'Phil Bryant') | ||
| } | ||
| } | ||
| scm { | ||
| connection.set( 'scm:git:https://github.com/Col-E/BentoFX.git') | ||
| developerConnection.set( 'scm:git:ssh://github.com/Col-E/BentoFX.git') | ||
| url.set( 'https://github.com/Col-E/BentoFX') | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| repositories { | ||
| mavenLocal() | ||
| maven { | ||
| url = uri(layout.buildDirectory.dir( 'staging-deploy')) | ||
| } | ||
| } | ||
|
Col-E marked this conversation as resolved.
|
||
| } | ||
14 changes: 14 additions & 0 deletions
14
build-logic/src/main/groovy/bento.test.unit-test-suite.gradle
|
Col-E marked this conversation as resolved.
|
This file contains hidden or 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,14 @@ | ||
| import static software.coley.gradle.lifecycle.BuildLifecycle.ALL_CLASSES_TASK_NAME | ||
|
|
||
| plugins { | ||
| id 'bento.project.build-lifecycle' | ||
| id 'jvm-test-suite' | ||
| } | ||
|
|
||
| tasks.named(ALL_CLASSES_TASK_NAME) { | ||
| dependsOn tasks.named('testClasses') | ||
| } | ||
|
|
||
| tasks.named('check') { | ||
| dependsOn(tasks.named('test')) | ||
| } |
14 changes: 14 additions & 0 deletions
14
build-logic/src/main/groovy/software/coley/gradle/artifacts/TestFxAlignmentRule.groovy
|
Col-E marked this conversation as resolved.
|
This file contains hidden or 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,14 @@ | ||
| package software.coley.gradle.artifacts | ||
|
|
||
| import org.gradle.api.artifacts.ComponentMetadataContext | ||
| import org.gradle.api.artifacts.ComponentMetadataRule | ||
|
|
||
| abstract class TestFxAlignmentRule implements ComponentMetadataRule { | ||
| @Override | ||
| void execute(ComponentMetadataContext ctx) { | ||
| def id = ctx.details.id | ||
| if (id.group == 'org.testfx' && id.name != 'openjfx-monocle') { | ||
| ctx.details.belongsTo("org.testfx:testfx-virtual-bom:${id.version}") | ||
| } | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
build-logic/src/main/groovy/software/coley/gradle/lifecycle/BuildLifecycle.groovy
|
Col-E marked this conversation as resolved.
|
This file contains hidden or 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 @@ | ||
| package software.coley.gradle.lifecycle | ||
|
|
||
| final class BuildLifecycle { | ||
| public static final String ALL_CLASSES_TASK_NAME = 'allClasses' | ||
|
|
||
| private BuildLifecycle() { | ||
| throw new UnsupportedOperationException( | ||
| 'Utility classes should not be instantiated.' | ||
| ) | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
...gic/src/main/groovy/software/coley/gradle/task/extensions/BentoConventionExtension.groovy
This file contains hidden or 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 software.coley.gradle.task.extensions | ||
|
|
||
| import org.gradle.api.provider.Provider | ||
|
|
||
| import javax.inject.Inject | ||
|
|
||
| /** | ||
| * Extension class for sharing lazily calculated values among precompiled | ||
| * convention script plugins. | ||
| */ | ||
| abstract class BentoConventionExtension { | ||
| /** | ||
| * The fully qualified project name, normalized as a valid for use as an | ||
| * artifact ID, JAR file name, etc. | ||
| */ | ||
| final Provider<String> normalizedProjectName | ||
|
|
||
| /** | ||
| * @param normalizedProjectName The fully qualified project name, | ||
| * normalized as a valid for use as an artifact ID, JAR file name, etc. | ||
| */ | ||
| @Inject | ||
| BentoConventionExtension(final Provider<String> normalizedProjectName) { | ||
| this.normalizedProjectName = normalizedProjectName | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.