Modernize Gradle buildscript #71
8
.github/workflows/build.yml
vendored
@ -22,6 +22,8 @@ jobs:
|
||||
steps:
|
||||
- name: checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- name: validate gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
- name: setup jdk ${{ matrix.java }}
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
@ -31,3 +33,9 @@ jobs:
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
- name: build
|
||||
run: ./gradlew build
|
||||
![]() 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/
|
||||
|
16
.github/workflows/validate-gradle-wrapper.yml
vendored
@ -1,16 +0,0 @@
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
![]() 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.
|
||||
![]() 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
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
# wrapper from a local gradle install.
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
name: validate gradle wrapper
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
on: [pull_request, push]
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
jobs:
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
build:
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
runs-on: ubuntu-20.04
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
steps:
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
- name: checkout repository
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
uses: actions/checkout@v2
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
- name: validate gradle wrapper
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
![]() Id just move this into the other workflow Id just move this into the other workflow
|
26
build.gradle
@ -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
|
||||
// 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.
|
||||
def targetVersion = JavaVersion.VERSION_1_8
|
||||
def targetVersion = 8
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
it.options.release = targetVersion.ordinal() + 1
|
||||
it.options.release = targetVersion
|
||||
} else {
|
||||
it.sourceCompatibility = targetVersion
|
||||
it.targetCompatibility = targetVersion
|
||||
it.sourceCompatibility = JavaVersion.toVersion(targetVersion)
|
||||
it.targetCompatibility = JavaVersion.toVersion(targetVersion)
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ java {
|
||||
|
||||
jar {
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${project.name}"}
|
||||
rename { "${it}_${project.archivesBaseName}"}
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,19 +74,9 @@ publishing {
|
||||
}
|
||||
![]() 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
|
||||
// to just publish to maven local, no extra repositories are necessary. Just use the task `publishToMavenLocal`.
|
||||
// Select the repositories you want to publish to
|
||||
// To publish to maven local, no extra repositories are necessary. Just use the task `publishToMavenLocal`.
|
||||
repositories {
|
||||
// An example of a standard Nexus setup, for those wishing to publish their mod artifacts
|
||||
// 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
|
||||
// }
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
}
|
||||
}
|
||||
![]() Does this work for sources in other source directories than Does this work for sources in other source directories than `java`, like Kotlin sources?
![]() It does. 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)
|
||||
|
This shouldnt be needed, it should be executable on the repo.
Depending on the method used to replicate this repo, the file mode may be lost. I don't think it should be removed.
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.