Modernize Gradle buildscript #71
No reviewers
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Steven/fabric-example-mod#71
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "feature/gradle-modernization"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR does a few things to modernize the buildscript and protect mod developers from accidental mistakes:
release
compiler flag where possible to more accurately compile for Java 8. When compiling on newer Java versions, this makes using API not available in Java 8 a compile error.pTML
task exists already), and replace it with an example for an actual repositoryfabric.mod.json
'ssuggests
object to use a mod name that isn't a mod that actually exists for FabricI've also bumped dependency versions while I was stopping by.
I don't think changing the
suggests
block is worthwhile, all you've done is create a mod with the idanother-mod
. Flamingo is at least a fairly small and harmless, and obviously joke-like, mod.Let's not talk about other people's mods like that :p
The point still stands: you're just playing cat and mouse with mod ids, and I'd rather it stay with a harmless mod than be opened to something potentially malicious. Have it suggest minecraft or a fapi module if you don't like flamigo.
@ -35,3 +35,3 @@
"flamingo": "*"
"another-mod": "*"
}
}
I would either keep this as flamingo or remote it all togeather.
I dont think many people use the suggests block, and there are 3 good examples on how to use the depends block so removing it seems fine. As good as flamingo is, its a bit of an in joke for the people that know about it, others it may just confuse.
@ -0,0 +18,4 @@
]
# and run on both Linux and Windows
os: [ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.os }}
I would just do ubuntu only, I dont think building on windows provides any benefit. Building on windows would double the amount of stuff to download, and increase the amount github has to build (I know its free, but dont want to wase it for the sake of it)
@ -0,0 +30,4 @@
java-version: ${{ matrix.java }}
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
This shouldnt be needed, it should be executable on the repo.
@ -0,0 +32,4 @@
if: ${{ runner.os != 'Windows' }}
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
Id just move this into the other workflow
This + 1 is a little odd looking, just hard coding it to 8 might be clearer
@ -51,3 +60,4 @@
}
}
// configure the maven publication
This is great, will need to add this to our other projects.
@ -64,9 +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
@ -0,0 +30,4 @@
java-version: ${{ matrix.java }}
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
Depending on the method used to replicate this repo, the file mode may be lost. I don't think it should be removed.
@ -70,3 +80,3 @@
// mavenLocal()
// 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
java
, like Kotlin sources?This is not that important, but this can cause problems if a project (most likely a library in this case) doesn't set the project name in gradle.properties. If it's built using Jitpack (for example for jij'ing), the file will be
LICENSE_build
as Gradle guesses the project name based on the directory, which Jitpack callsbuild
.@ -70,3 +80,3 @@
// mavenLocal()
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
}
}
It does.
withSourcesJar()
collects its source fromSourceSet.getAllSource()
ah -- I usually set the project name in
settings.gradle
. I might update this PR to skip settingarchivesBaseName
and instead just set the project name explicitly.@ -0,0 +30,4 @@
java-version: ${{ matrix.java }}
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
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, it's a bit of an unfortunate workaround to the fact that
JavaVersion.getMajorVersion()
returns a String of the same value, and not an int. If only Gradle didn't have 3 separate ways to represent a Java version in different parts of its API....Can probably avoid it though by declaring
targetVersion
as an int, and converting that toJavaVersion
for the pre-Java9 variant.@ -0,0 +18,4 @@
]
# and run on both Linux and Windows
os: [ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.os }}
I've run into platform-specific issues before, in my own projects and what I've seen in some other repos:
git
.These can be caught by running CI builds on multiple operating systems.
@ -35,3 +35,3 @@
"flamingo": "*"
"another-mod": "*"
}
}
will remove... if only JSON allowed comments, would be a good way to explain some things inline
@ -35,3 +35,3 @@
"flamingo": "*"
"another-mod": "*"
}
}
This ended up being merged with
another-mod
instead offlamingo
or nothing...