diff --git a/.gitignore b/.gitignore index 1d4f18f..efdb371 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # eclipse bin +oldBuilds *.launch .settings .metadata @@ -22,4 +23,3 @@ build eclipse run -gradle\.properties diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..fee8f5e --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,25 @@ +#!/usr/bin/env groovy + +pipeline { + agent any + stages { + stage('Clean') { + steps { + echo 'Cleaning Project' + sh 'chmod +x gradlew' + sh './gradlew clean' + } + } + stage('Build and Deploy') { + steps { + echo 'Building and Deploying to Maven' + sh './gradlew build publish' + } + } + } + post { + always { + archive 'build/libs/**.jar' + } + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 40cf5f9..798d264 100644 --- a/build.gradle +++ b/build.gradle @@ -13,8 +13,9 @@ buildscript { apply plugin: 'net.minecraftforge.gradle.forge' +apply plugin: 'maven-publish' -version = "1.0" +version = "${minecraft_version}-${version}" group = "tschipp.carryon" archivesBaseName = "carryon" @@ -23,6 +24,10 @@ compileJava { sourceCompatibility = targetCompatibility = '1.8' } +if (System.getenv('BUILD_NUMBER') != null) { + version += "." + System.getenv('BUILD_NUMBER') +} + minecraft { version = "1.12.2-14.23.5.2847" runDir = "run" @@ -53,6 +58,76 @@ dependencies { } +task sourcesJar(type: Jar, dependsOn: classes) { + description = 'Creates a JAR containing the source code.' + from sourceSets.main.allSource + classifier = 'sources' +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + description = 'Creates a JAR containing the JavaDocs.' + from javadoc.destinationDir + classifier = 'javadoc' +} + +task deobfJar(type: Jar) { + description = 'Creates a JAR containing the non-obfuscated compiled code.' + from sourceSets.main.output + classifier = "deobf" +} + +artifacts { + archives sourcesJar + archives javadocJar + archives deobfJar +} + +publishing { + + publications { + + mavenJava(MavenPublication) { + + groupId project.group + artifactId project.archivesBaseName + version project.version + from components.java + + // Allows the maven pom file to be modified. + pom.withXml { + + // Go through all the dependencies. + asNode().dependencies.dependency.each { dep -> + + println 'Surpressing artifact ' + dep.artifactId.last().value().last() + ' from maven dependencies.' + assert dep.parent().remove(dep) + } + } + + artifact sourcesJar { + + classifier 'sources' + } + artifact javadocJar { + + classifier 'javadoc' + } + artifact deobfJar { + + classifier 'deobf' + } + } + } + + repositories { + + maven { + + url "file://" + System.getenv("local_maven") + } + } +} + processResources { inputs.property "version", project.version diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..e5876ac --- /dev/null +++ b/gradle.properties @@ -0,0 +1,5 @@ +# Sets default memory used for gradle commands. Can be overridden by user or command line properties. +# This is required to provide enough memory for the Minecraft decompilation process. +org.gradle.jvmargs=-Xmx3G +version=1.12.3 +minecraft_version=1.12.2 \ No newline at end of file diff --git a/src/main/java/tschipp/carryon/common/helper/ReflectionUtil.java b/src/main/java/tschipp/carryon/common/helper/ReflectionUtil.java index 4a8d037..7fc5c51 100644 --- a/src/main/java/tschipp/carryon/common/helper/ReflectionUtil.java +++ b/src/main/java/tschipp/carryon/common/helper/ReflectionUtil.java @@ -16,19 +16,7 @@ import net.minecraftforge.fml.relauncher.ReflectionHelper; */ public class ReflectionUtil { - /** - * Get a {@link MethodHandle} for a method. - * - * @param clazz - * The class - * @param methodNames - * The possible names of the method - * @param methodTypes - * The argument types of the method - * @param - * The class - * @return The MethodHandle - */ + public static MethodHandle findMethod(final Class clazz, final String methodName, @Nullable final String methodObfName, final Class... parameterTypes) { final Method method = ReflectionHelper.findMethod(clazz, methodName, methodObfName, parameterTypes); @@ -42,15 +30,7 @@ public class ReflectionUtil } } - /** - * Get a {@link MethodHandle} for a field's getter. - * - * @param clazz - * The class - * @param fieldNames - * The possible names of the field - * @return The MethodHandle - */ + public static MethodHandle findFieldGetter(Class clazz, String... fieldNames) { final Field field = ReflectionHelper.findField(clazz, fieldNames); @@ -65,15 +45,7 @@ public class ReflectionUtil } } - /** - * Get a {@link MethodHandle} for a field's setter. - * - * @param clazz - * The class - * @param fieldNames - * The possible names of the field - * @return The MethodHandle - */ + public static MethodHandle findFieldSetter(Class clazz, String... fieldNames) { final Field field = ReflectionHelper.findField(clazz, fieldNames);