Update for new build script

This commit is contained in:
Johannes Frohnmeyer 2021-11-29 20:36:43 +01:00
parent 97b9307cfd
commit 8f1e5a54e9
Signed by: Johannes
GPG Key ID: E76429612C2929F4
3 changed files with 11 additions and 328 deletions

View File

@ -1,33 +1,2 @@
image: gradle:jdk17
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
stages:
- build
- deploy
build_test:
stage: build
script:
- gradle --build-cache build publish -Ppublic
- cp build/libs/* ./
- rm *-maven.jar *-sources.jar *-sources-dev.jar
- mv *-dev.jar dev.zip
- mv *.jar latest.jar
- mv dev.zip latest-dev.jar
artifacts:
paths:
- build/libs
- latest.jar
- latest-dev.jar
deploy:
rules:
- if: $CI_COMMIT_TAG && '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /^master/'
stage: deploy
script:
- gradle --build-cache build publish modrinth curseforge -Ppublic -Prelease
include:
- remote: 'https://jfmods.gitlab.io/scripts/jfmod.yml'

View File

@ -1,102 +1,6 @@
import com.modrinth.minotaur.TaskModrinthUpload
import com.modrinth.minotaur.request.VersionType
import java.time.Instant
plugins {
id "java"
id "idea"
id "eclipse"
id "java-library"
id "maven-publish"
id "fabric-loom" version "0.10-SNAPSHOT" apply false
id "com.matthewprenger.cursegradle" version "1.4.0"
id "com.modrinth.minotaur" version "1.2.1"
id "org.ajoberstar.grgit" version "3.1.0"
}
def ENV = System.getenv()
ext.isPublicMaven = project.hasProperty('public')
// Fetch changelog
grgit.open(dir: project.projectDir.toString())
def tagList = grgit.tag.list()
def currentTag = tagList.get(tagList.size() - 1)
ext.currentVer = currentTag.getName()
ext.currentType = VersionType.RELEASE
switch (ext.currentVer[0]) {
case 'v':
ext.currentVer = ext.currentVer.substring(1)
break
case 'b':
ext.currentVer = ext.currentVer.substring(1)
ext.currentType = VersionType.BETA
break
case 'a':
ext.currentVer = ext.currentVer.substring(1)
ext.currentType = VersionType.ALPHA
break
}
def changelogStr = "Commits in " + ext.currentType.toString().toLowerCase() + " " + ext.currentVer + ":"
for (def commit : grgit.log{range(tagList.get(tagList.size() - 2).fullName, currentTag.fullName)}) {
changelogStr += "\n- " + commit.shortMessage
}
if (!project.hasProperty("release")) {
ext.currentVer += "-" + Instant.now().getEpochSecond()
}
println(changelogStr)
static Node getOrCreateNode(Node node, String name) {
Node dependencies = null
for(Node n : node) {
if(name == n.name()) {
dependencies = n
break
}
}
if(dependencies == null) {
dependencies = node.appendNode(name)
}
return dependencies
}
def moduleDependencies(project, List<String> depNames) {
def deps = depNames.iterator().collect { project.dependencies.project(path: ":$it", configuration: 'dev') }
project.dependencies {
deps.each {
api it
}
}
project.publishing {
publications {
mavenJava(MavenPublication) {
pom.withXml {
def depsNode = getOrCreateNode(asNode(), "dependencies")
deps.each {
def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", it.group)
depNode.appendNode("artifactId", it.name)
depNode.appendNode("version", it.version)
depNode.appendNode("scope", "compile")
}
}
}
}
}
}
apply from: "https://jfmods.gitlab.io/scripts/jfmod.gradle"
allprojects {
apply plugin: "java-library"
apply plugin: "maven-publish"
apply plugin: "fabric-loom"
tasks.withType(JavaCompile).configureEach {
it.options.release = 17
}
group = "io.gitlab.jfronny.libjf"
version = "$rootProject.ext.currentVer"
sourceSets {
testmod {
compileClasspath += main.compileClasspath
@ -122,213 +26,17 @@ allprojects {
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.minecraft_version}+${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modRuntimeOnly modCompileOnly("com.terraformersmc:modmenu:2.0.14")
modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
}
configurations {
dev
}
loom {
shareRemapCaches = true
}
repositories {
maven {
name = 'TerraformersMC'
url = 'https://maven.terraformersmc.com/'
}
mavenLocal()
}
jar {
archiveClassifier = "dev"
}
afterEvaluate {
remapJar {
input = file("${project.buildDir}/libs/$archivesBaseName-${project.version}-dev.jar")
archiveFileName = "${archivesBaseName}-${project.version}.jar"
}
artifacts {
dev file: file("${project.buildDir}/libs/$archivesBaseName-${project.version}-dev.jar"), type: "jar", builtBy: jar
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = "sources"
from sourceSets.main.allSource
}
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
}
subprojects {
dependencies {
testmodImplementation sourceSets.main.output
}
publishing {
publications {
mavenJava(MavenPublication) {
afterEvaluate {
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
}
setupRepositories(repositories)
}
loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
javadoc.enabled = false
afterEvaluate {
genSources.enabled = false
unpickJar.enabled = false
}
}
task remapMavenJar(type: net.fabricmc.loom.task.RemapJarTask, dependsOn: jar) {
input = jar.archiveFile
archiveFileName = "${archivesBaseName}-${project.version}-maven.jar"
addNestedDependencies = false
}
build.dependsOn remapMavenJar
publishing {
publications {
mavenJava(MavenPublication) {
artifact(remapMavenJar) {
builtBy remapMavenJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
pom.withXml {
def depsNode = getOrCreateNode(asNode(), "dependencies")
subprojects.each {
def depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", it.group)
depNode.appendNode("artifactId", it.name)
depNode.appendNode("version", it.version)
depNode.appendNode("scope", "compile")
}
}
}
}
setupRepositories(repositories)
}
loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
void setupRepositories(RepositoryHandler repositories) {
//repositories.mavenLocal() // uncomment for testing
def ENV = System.getenv()
if (ext.isPublicMaven) {
repositories.maven {
url = "https://gitlab.com/api/v4/projects/25805200/packages/maven"
name = "gitlab"
credentials(HttpHeaderCredentials) {
name = "Job-Token"
value = ENV.CI_JOB_TOKEN
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
repositories.mavenLocal()
}
subprojects.each { remapJar.dependsOn("${it.path}:remapJar") }
sourceSets {
testmod
}
def devOnlyModules = [
"libjf-devutil-v0"
]
dependencies {
afterEvaluate {
subprojects.each {
api project(path: ":${it.name}", configuration: "dev")
if (!(it.name in devOnlyModules)) {
include it
}
testmodImplementation it.sourceSets.testmod.output
}
}
}
task modrinth(type: TaskModrinthUpload, dependsOn: build) {
onlyIf {
ENV.MODRINTH_API_TOKEN
}
token = ENV.MODRINTH_API_TOKEN
projectId = "WKwQAwke"
versionNumber = version
versionName = "[${project.minecraft_version}] ${version}"
uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")
versionType = rootProject.ext.currentType
changelog = changelogStr
addGameVersion("${project.minecraft_version}")
addLoader('fabric')
}
curseforge {
if (ENV.CURSEFORGE_API_TOKEN) {
apiKey = ENV.CURSEFORGE_API_TOKEN
} else {
println "No CURSEFORGE_API_TOKEN specified"
}
project {
id = "482600"
releaseType = 'release'
addGameVersion "Fabric"
addGameVersion "${project.minecraft_version}"
changelog = changelogStr
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"))
mainArtifact.displayName = "[${project.minecraft_version}] ${version}"
releaseType = rootProject.ext.currentType.toString().toLowerCase()
afterEvaluate {
uploadTask.dependsOn(build)
}
}
options {
forgeGradleIntegration = false
}
}

View File

@ -1,6 +1,12 @@
org.gradle.jvmargs=-Xmx1G
# https://fabricmc.net/versions.html
minecraft_version=1.18-rc3
yarn_mappings=build.2
minecraft_version=1.18-rc4
yarn_mappings=build.1
loader_version=0.12.5
fabric_version=0.43.1+1.18
maven_group=io.gitlab.jfronny.libjf
archive_base_name=libjf
dev_only_module=libjf-devutil-v0
modrinth_id=WKwQAwke
curseforge_id=482600