From c75c837050ed6ef9cd5f6d29718e785def4ce411 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 1 May 2020 15:52:09 +0800 Subject: Jar Filter Signed-off-by: shedaniel --- build.gradle | 53 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 16 deletions(-) (limited to 'build.gradle') diff --git a/build.gradle b/build.gradle index 1082bab5e..20b4ab8dc 100755 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,16 @@ -import net.fabricmc.loom.task.RemapJarTask - -import java.text.SimpleDateFormat - plugins { id 'fabric-loom' version '0.4.3' id 'maven-publish' + id 'java' + id 'java-library' id 'net.minecrell.licenser' version '0.4.1' id 'com.matthewprenger.cursegradle' version '1.4.0' + id 'net.corda.plugins.jar-filter' version "5.0.8" apply false } +import net.fabricmc.loom.task.RemapJarTask +import java.text.SimpleDateFormat + sourceCompatibility = targetCompatibility = 1.8 archivesBaseName = "RoughlyEnoughItems" @@ -24,12 +26,6 @@ minecraft { accessWidener = file("src/main/resources/rei.aw") } -static def buildTime() { - def df = new SimpleDateFormat("yyyyMMddHHmm") - df.setTimeZone(TimeZone.getTimeZone("UTC")) - return df.format(new Date()) -} - license { header rootProject.file('HEADER') include '**/*.java' @@ -98,8 +94,30 @@ dependencies { } } +task jarFilter(type: net.corda.gradle.jarfilter.JarFilterTask) { + jars remapJar + annotations { + forRemove = [ + "org.jetbrains.annotations.NotNull", + "org.jetbrains.annotations.Nullable", + "org.jetbrains.annotations.ApiStatus\$Experimental", + "org.jetbrains.annotations.ApiStatus\$Internal", + "org.jetbrains.annotations.ApiStatus\$ScheduledForRemoval", + "org.jetbrains.annotations.ApiStatus\$AvailableSince", + "org.jetbrains.annotations.ApiStatus\$NonExtendable", + "org.jetbrains.annotations.ApiStatus\$OverrideOnly" + ] + } +} + +task copyJarFilter(type: Copy) { + from jarFilter + into "${project.buildDir}/filtered-libs/" + rename { "${project.archivesBaseName}-${project.version}.jar" } +} + task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" + classifier("sources") from sourceSets.main.allSource } @@ -123,7 +141,7 @@ task releaseOnCf { def branch if (System.env.BRANCH_NAME) { branch = System.env.BRANCH_NAME - branch = branch.substring(branch.lastIndexOf("/")+1) + branch = branch.substring(branch.lastIndexOf("/") + 1) } else { branch = "git rev-parse --abbrev-ref HEAD".execute().in.text.trim() } @@ -133,11 +151,11 @@ task releaseOnCf { def time = df.format(new Date()) def changes = new StringBuilder() changes << "

REI v$project.version for $project.supported_version

Updated at $time.
Click here for changelog" - def proc = "git log --max-count=200 --pretty=format:\"%s\"".execute() + def proc = "git log --max-count=200 --pretty=format:%s".execute() proc.in.eachLine { line -> def processedLine = line.toString() if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) { - changes << "
- $processedLine" + changes << "
- ${processedLine.capitalize()}" } } proc.waitFor() @@ -161,11 +179,14 @@ curseforge { embeddedLibrary 'cloth' embeddedLibrary 'cloth-config' } - mainArtifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}.jar")) { + mainArtifact(file("${project.buildDir}/filtered-libs/${project.archivesBaseName}-${project.version}.jar")) { displayName = "[Fabric $project.supported_version] v$project.version" } + addArtifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}-sources.jar")) { + displayName = "[Fabric $project.supported_version] v$project.version Sources" + } afterEvaluate { - uploadTask.dependsOn("remapJar") + uploadTask.dependsOn("copyJarFilter") } } } -- cgit