Modernize Gradle buildscript #71

Merged
zml2008 merged 4 commits from feature/gradle-modernization into master 2020-11-10 22:11:54 +00:00
3 changed files with 16 additions and 34 deletions
Showing only changes of commit 09d8031c6c - Show all commits

View File

@ -22,6 +22,8 @@ jobs:
steps: steps:
- name: checkout repository - name: checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: setup jdk ${{ matrix.java }} - name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
@ -31,3 +33,9 @@ jobs:
run: chmod +x ./gradlew run: chmod +x ./gradlew
modmuss50 commented 2020-11-02 10:57:15 +00:00 (Migrated from github.com)
Review

This shouldnt be needed, it should be executable on the repo.

This shouldnt be needed, it should be executable on the repo.
JamiesWhiteShirt commented 2020-11-02 16:12:49 +00:00 (Migrated from github.com)
Review

Depending on the method used to replicate this repo, the file mode may be lost. I don't think it should be removed.

Depending on the method used to replicate this repo, the file mode may be lost. I don't think it should be removed.
zml2008 commented 2020-11-03 05:41:09 +00:00 (Migrated from github.com)
Review

Yeah, windows generally doesn't preserve file permissions -- I've had it happen a few times before when setting up gradle wrapper.

There's no harm to keeping it there -- it'll basically be a no-op if the repo is set up correctly, but removes one more thing that could go wrong.

Yeah, windows generally doesn't preserve file permissions -- I've had it happen a few times before when setting up gradle wrapper. There's no harm to keeping it there -- it'll basically be a no-op if the repo is set up correctly, but removes one more thing that could go wrong.
- name: build - name: build
run: ./gradlew build run: ./gradlew build
modmuss50 commented 2020-11-02 10:59:18 +00:00 (Migrated from github.com)
Review

Saving the build artifacts after this might not be a bad idea. Make sure to only do it on one java version

Saving the build artifacts after this might not be a bad idea. Make sure to only do it on one java version
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '11' }} # Only upload artifacts built from LTS java on one OS
uses: actions/upload-artifact@v2
with:
name: Artifacts
path: build/libs/

View File

@ -1,16 +0,0 @@
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
# Ensure the gradle wrapper in the repository has not been tampered with.
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
# If this check fails, something is seriously wrong -- try creating a new
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
# wrapper from a local gradle install.
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
name: validate gradle wrapper
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
on: [pull_request, push]
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
jobs:
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
build:
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
runs-on: ubuntu-20.04
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
steps:
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
- name: checkout repository
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
uses: actions/checkout@v2
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
- name: validate gradle wrapper
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow
uses: gradle/wrapper-validation-action@v1
modmuss50 commented 2020-11-02 10:55:34 +00:00 (Migrated from github.com)
Review

Id just move this into the other workflow

Id just move this into the other workflow

View File

@ -38,12 +38,12 @@ tasks.withType(JavaCompile).configureEach {
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option. // We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = JavaVersion.VERSION_1_8 def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) { if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion.ordinal() + 1 it.options.release = targetVersion
} else { } else {
it.sourceCompatibility = targetVersion it.sourceCompatibility = JavaVersion.toVersion(targetVersion)
it.targetCompatibility = targetVersion it.targetCompatibility = JavaVersion.toVersion(targetVersion)
} }
} }
@ -56,7 +56,7 @@ java {
jar { jar {
from("LICENSE") { from("LICENSE") {
rename { "${it}_${project.name}"} rename { "${it}_${project.archivesBaseName}"}
} }
} }
@ -74,19 +74,9 @@ publishing {
} }
modmuss50 commented 2020-11-02 10:02:02 +00:00 (Migrated from github.com)
Review

I dont think this is really needed, its another thing to confuse new develeops. Very few people publish to maven, and if so there are good docs online? Possbly just link to https://docs.gradle.org/current/userguide/publishing_maven.html

I dont think this is really needed, its another thing to confuse new develeops. Very few people publish to maven, and if so there are good docs online? Possbly just link to https://docs.gradle.org/current/userguide/publishing_maven.html
} }
// select the repositories you want to publish to // Select the repositories you want to publish to
// to just publish to maven local, no extra repositories are necessary. Just use the task `publishToMavenLocal`. // To publish to maven local, no extra repositories are necessary. Just use the task `publishToMavenLocal`.
repositories { repositories {
// An example of a standard Nexus setup, for those wishing to publish their mod artifacts // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
// maven {
// if (project.version.endsWith("-SNAPSHOT")) {
// url = "https://nexus.myorganization.org/repository/maven-snapshots/"
// } else {
// url = "https://nexus.myorganization.org/repository/maven-releases/"
// }
// name = "myRepo"
// credentials(PasswordCredentials) // use the ${name}Username and ${name}Password properties for authentication
// }
} }
} }
Juuxel commented 2020-11-02 17:02:55 +00:00 (Migrated from github.com)
Review

Does this work for sources in other source directories than java, like Kotlin sources?

Does this work for sources in other source directories than `java`, like Kotlin sources?
zml2008 commented 2020-11-03 05:21:39 +00:00 (Migrated from github.com)
Review
It does. `withSourcesJar()` [collects its source from `SourceSet.getAllSource()`](https://github.com/gradle/gradle/blob/a24197ee1f665acd9ed93f345eb5b7f788385151/subprojects/plugins/src/main/java/org/gradle/api/plugins/internal/DefaultJavaPluginExtension.java#L125)