Skip to content

Commit 23ddc7b

Browse files
committed
Add Jenkinsfile for new Jenkins server.
Move some @Input/@output annotations to getters, to make them potentially function. Attempted fix for invalid injection during jenkins build.
1 parent 41e1860 commit 23ddc7b

File tree

7 files changed

+115
-38
lines changed

7 files changed

+115
-38
lines changed

Jenkinsfile

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
@Library('forge-shared-library')_
2+
3+
pipeline {
4+
agent {
5+
docker {
6+
image 'gradlewrapper:latest'
7+
args '-v gradlecache:/gradlecache'
8+
}
9+
}
10+
environment {
11+
GRADLE_ARGS = '-Dorg.gradle.daemon.idletimeout=5000'
12+
DISCORD_WEBHOOK = credentials('forge-discord-jenkins-webhook')
13+
DISCORD_PREFIX = "Job: ForgeGradle Branch: ${BRANCH_NAME} Build: #${BUILD_NUMBER}"
14+
JENKINS_HEAD = 'https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png'
15+
}
16+
17+
stages {
18+
stage('fetch') {
19+
steps {
20+
checkout scm
21+
}
22+
}
23+
stage('notify_start') {
24+
when {
25+
not {
26+
changeRequest()
27+
}
28+
}
29+
steps {
30+
discordSend(
31+
title: "${DISCORD_PREFIX} Started",
32+
successful: true,
33+
result: 'ABORTED', //White border
34+
thumbnail: JENKINS_HEAD,
35+
webhookURL: DISCORD_WEBHOOK
36+
)
37+
}
38+
}
39+
stage('buildandtest') {
40+
steps {
41+
sh './gradlew ${GRADLE_ARGS} --refresh-dependencies --continue build' # test'
42+
script {
43+
env.MYVERSION = sh(returnStdout: true, script: './gradlew properties -q | grep "version:" | awk \'{print $2}\'').trim()
44+
}
45+
}
46+
/*
47+
post {
48+
success {
49+
writeChangelog(currentBuild, 'build/changelog.txt')
50+
archiveArtifacts artifacts: 'build/changelog.txt', fingerprint: false
51+
}
52+
}
53+
*/
54+
}
55+
stage('publish') {
56+
when {
57+
not {
58+
changeRequest()
59+
}
60+
}
61+
environment {
62+
FORGE_MAVEN = credentials('forge-maven-forge-user')
63+
}
64+
steps {
65+
sh './gradlew ${GRADLE_ARGS} uploadArchives -PforgeMavenUser=${FORGE_MAVEN_USR} -PforgeMavenPassword=${FORGE_MAVEN_PSW}'
66+
}
67+
}
68+
}
69+
post {
70+
always {
71+
script {
72+
archiveArtifacts artifacts: 'build/libs/**/*.jar', fingerprint: true
73+
74+
if (env.CHANGE_ID == null) { // This is unset for non-PRs
75+
discordSend(
76+
title: "${DISCORD_PREFIX} Finished ${currentBuild.currentResult}",
77+
description: '```\n' + getChanges(currentBuild) + '\n```',
78+
successful: currentBuild.resultIsBetterOrEqualTo("SUCCESS"),
79+
result: currentBuild.currentResult,
80+
thumbnail: JENKINS_HEAD,
81+
webhookURL: DISCORD_WEBHOOK
82+
)
83+
}
84+
}
85+
}
86+
}
87+
}

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,10 @@ uploadArchives {
355355

356356
dependsOn 'build'
357357

358-
if (project.hasProperty('forgeMavenPass'))
358+
if (project.hasProperty('forgeMavenPassword'))
359359
{
360360
repository(url: "https://files.minecraftforge.net/maven/manage/upload") {
361-
authentication(userName: "forge", password: project.getProperty('forgeMavenPass'))
361+
authentication(userName: project.getProperty('forgeMavenUser'), password: project.getProperty('forgeMavenPassword'))
362362
}
363363
}
364364
else

src/main/java/net/minecraftforge/gradle/tasks/AbstractEditJarTask.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@
4444

4545
public abstract class AbstractEditJarTask extends CachedTask
4646
{
47-
@InputFile
4847
private Object inJar;
49-
50-
@Cached
51-
@OutputFile
5248
private Object outJar;
5349

5450
protected File resolvedInJar;
@@ -264,6 +260,7 @@ private void copyJar(File input, File output) throws Exception
264260
}
265261
}
266262

263+
@InputFile
267264
public File getInJar()
268265
{
269266
return getProject().file(inJar);
@@ -274,6 +271,8 @@ public void setInJar(Object inJar)
274271
this.inJar = inJar;
275272
}
276273

274+
@OutputFile
275+
@Cached
277276
public File getOutJar()
278277
{
279278
return getProject().file(outJar);

src/main/java/net/minecraftforge/gradle/tasks/PatchSourcesTask.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,11 @@ public class PatchSourcesTask extends AbstractEditJarTask
5959
* 4) ????
6060
* 5) profit from multithreaded oatching. Its CPU bound anyways.
6161
*/
62-
63-
@Input
6462
private int maxFuzz = 0;
65-
66-
@Input
6763
private int patchStrip = 3;
68-
69-
@Input
7064
private boolean makeRejects = true;
71-
72-
@Input
7365
private boolean failOnError = false;
74-
7566
private Object patches;
76-
77-
@InputFiles
7867
private List<Object> injects = Lists.newArrayList();
7968

8069
// stateful pieces of this task
@@ -302,6 +291,7 @@ else if (report.getStatus() == ContextualPatch.PatchStatus.Fuzzed)
302291

303292
// START GETTERS/SETTERS HERE
304293

294+
@Input
305295
public int getMaxFuzz()
306296
{
307297
return maxFuzz;
@@ -312,6 +302,7 @@ public void setMaxFuzz(int maxFuzz)
312302
this.maxFuzz = maxFuzz;
313303
}
314304

305+
@Input
315306
public int getPatchStrip()
316307
{
317308
return patchStrip;
@@ -322,6 +313,7 @@ public void setPatchStrip(int patchStrip)
322313
this.patchStrip = patchStrip;
323314
}
324315

316+
@Input
325317
public boolean isMakeRejects()
326318
{
327319
return makeRejects;
@@ -332,6 +324,7 @@ public void setMakeRejects(boolean makeRejects)
332324
this.makeRejects = makeRejects;
333325
}
334326

327+
@Input
335328
public boolean isFailOnError()
336329
{
337330
return failOnError;
@@ -364,6 +357,7 @@ private File getPatchesZip()
364357
return getPatches();
365358
}
366359

360+
@InputFiles
367361
public File getPatches()
368362
{
369363
return getProject().file(patches);
@@ -374,6 +368,7 @@ public void setPatches(Object patchDir)
374368
this.patches = patchDir;
375369
}
376370

371+
@InputFiles
377372
public FileCollection getInjects()
378373
{
379374
return getProject().files(injects);

src/main/java/net/minecraftforge/gradle/tasks/PostDecompileTask.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
import net.minecraftforge.gradle.common.Constants;
3737
import net.minecraftforge.gradle.util.ThrowableUtil;
38-
import net.minecraftforge.gradle.util.caching.Cached;
3938
import net.minecraftforge.gradle.util.delayed.DelayedFile;
4039
import net.minecraftforge.gradle.util.mcp.FFPatcher;
4140
import net.minecraftforge.gradle.util.mcp.GLConstantFixer;
@@ -50,7 +49,6 @@
5049
import org.gradle.api.logging.Logger;
5150
import org.gradle.api.tasks.InputFile;
5251
import org.gradle.api.tasks.InputFiles;
53-
import org.gradle.api.tasks.OutputFile;
5452

5553
import com.github.abrarsyed.jastyle.ASFormatter;
5654
import com.github.abrarsyed.jastyle.OptParser;
@@ -65,19 +63,10 @@
6563

6664
public class PostDecompileTask extends AbstractEditJarTask
6765
{
68-
@InputFile
69-
private Object inJar;
70-
7166
private Object patchDir;
7267
private Object injectDir;
73-
74-
@InputFile
7568
private Object astyleConfig;
7669

77-
@OutputFile
78-
@Cached
79-
private Object outJar;
80-
8170
//private static final Pattern BEFORE = Pattern.compile("(?m)((case|default).+(?:\\r\\n|\\r|\\n))(?:\\r\\n|\\r|\\n)");
8271
//private static final Pattern AFTER = Pattern.compile("(?m)(?:\\r\\n|\\r|\\n)((?:\\r\\n|\\r|\\n)[ \\t]+(case|default))");
8372

@@ -182,9 +171,10 @@ protected void postWrite(JarOutputStream jarOut) throws IOException
182171
if (info.exists())
183172
{
184173
String template = Resources.toString(info.toURI().toURL(), Charsets.UTF_8);
185-
getLogger().debug("Adding package-infos");
174+
getLogger().info("Adding package-infos");
186175
for (String pkg : this.seenPackages)
187176
{
177+
getLogger().info(" " + pkg + "/package-info.java");
188178
jarOut.putNextEntry(new ZipEntry(pkg + "/package-info.java"));
189179
jarOut.write(template.replaceAll("\\{PACKAGE\\}", pkg.replace('/', '.')).getBytes());
190180
jarOut.closeEntry();
@@ -193,9 +183,15 @@ protected void postWrite(JarOutputStream jarOut) throws IOException
193183
File common = new File(file, "common/");
194184
if (common.isDirectory())
195185
{
186+
String root = common.getAbsolutePath().replace('\\', '/');
187+
if (!root.endsWith("/")) root += '/';
188+
getLogger().info("Inject Root: " + root);
189+
196190
for (File f : this.getProject().fileTree(common))
197191
{
198-
String name = f.getAbsolutePath().substring(common.getAbsolutePath().length() + 1).replace('\\', '/');
192+
String full = f.getAbsolutePath().replace('\\', '/');
193+
String name = full.substring(root.length());
194+
getLogger().info(" Injecting: " + name);
199195
jarOut.putNextEntry(new ZipEntry(name));
200196
jarOut.write(Resources.toByteArray(f.toURI().toURL()));
201197
jarOut.closeEntry();
@@ -285,6 +281,7 @@ private static ContextualPatch findPatch(Collection<File> files, ContextProvider
285281
return patch;
286282
}
287283

284+
@InputFile
288285
public File getAstyleConfig()
289286
{
290287
return getProject().file(astyleConfig);

src/main/java/net/minecraftforge/gradle/tasks/RemapSources.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import net.minecraftforge.gradle.util.delayed.DelayedFile;
3030
import net.minecraftforge.gradle.util.mcp.JavadocAdder;
3131

32+
import org.gradle.api.tasks.Input;
3233
import org.gradle.api.tasks.InputFile;
3334

3435
import au.com.bytecode.opencsv.CSVReader;
@@ -41,15 +42,9 @@
4142

4243
public class RemapSources extends AbstractEditJarTask
4344
{
44-
@InputFile
4545
private DelayedFile methodsCsv;
46-
47-
@InputFile
4846
private DelayedFile fieldsCsv;
49-
50-
@InputFile
5147
private DelayedFile paramsCsv;
52-
5348
private boolean addsJavadocs = true;
5449

5550
private final Map<String, String> methods = Maps.newHashMap();
@@ -187,6 +182,7 @@ else if (find.startsWith("field_"))
187182
return buf.toString();
188183
}
189184

185+
@InputFile
190186
public File getMethodsCsv()
191187
{
192188
return methodsCsv.call();
@@ -197,6 +193,7 @@ public void setMethodsCsv(DelayedFile methodsCsv)
197193
this.methodsCsv = methodsCsv;
198194
}
199195

196+
@InputFile
200197
public File getFieldsCsv()
201198
{
202199
return fieldsCsv.call();
@@ -207,6 +204,7 @@ public void setFieldsCsv(DelayedFile fieldsCsv)
207204
this.fieldsCsv = fieldsCsv;
208205
}
209206

207+
@InputFile
210208
public File getParamsCsv()
211209
{
212210
return paramsCsv.call();
@@ -217,6 +215,7 @@ public void setParamsCsv(DelayedFile paramsCsv)
217215
this.paramsCsv = paramsCsv;
218216
}
219217

218+
@Input
220219
public boolean addsJavadocs()
221220
{
222221
return addsJavadocs;

src/main/resources/GradleStartServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ public static void main(String[] args) throws Throwable
99
{
1010
(new GradleStartServer()).launch(args);
1111
}
12-
12+
1313
@Override
1414
protected String getTweakClass()
1515
{
1616
return "@@TWEAKERSERVER@@";
1717
}
18-
18+
1919
@Override
2020
protected String getBounceClass()
2121
{

0 commit comments

Comments
 (0)