Skip to content

Commit

Permalink
Use ForgeGradle-standard way to set versions.
Browse files Browse the repository at this point in the history
This 'works around' a 'bug' in runclient. At any rate, runclient now works, and
there's less code. Yay.
  • Loading branch information
Baughn committed Oct 30, 2016
1 parent 58652d7 commit eac6d48
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
21 changes: 7 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ apply from: 'gradle.properties'

group = GROUP
archivesBaseName = ARCHIVE_NAME
version = MAJORVERSION + "." + MINORVERSION + "." + REVISION

targetCompatibility = '1.6'
sourceCompatibility = '1.6'
Expand All @@ -51,6 +52,12 @@ minecraft {
// TODO(Baughn): After moving to 1.10, this should be replaced with the shadow plugin,
// e.g. as used in https://github.com/Emberwalker/Laundarray/blob/master/build.gradle
srgExtra "PK: org/apache/commons/math3 mods/eln/libs/org/apache/commons/math3"

replaceIn "Version.java"
replace "@VERSION@", project.version
replace "@MAJORVERSION@", MAJORVERSION
replace "@MINORVERSION@", MINORVERSION
replace "@REVISION@", REVISION
}

configurations {
Expand Down Expand Up @@ -177,20 +184,6 @@ def getMinecratfDir() {
return outDir
}

task readVersion(type: JavaExec, dependsOn: classes) {
classpath configurations.runtime, sourceSets.main.output
main = "mods.eln.misc.Version"
standardOutput = new ByteArrayOutputStream()
doLast {
project.setVersion(standardOutput.toString())
jar.manifest {
attributes 'Implementation-Version': project.version
}
}
}

jar.dependsOn('readVersion')

// Custom task to build and copy the mod Jar to the default local Minecraft folder
task buildAndCopyJar(dependsOn: 'build', type: Copy) {
group = 'ELN'
Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
MAJORVERSION = 1
MINORVERSION = 12
REVISION = 0

GROUP = 'net.electricalage.eln'
ARCHIVE_NAME = 'ElectricalAge'
MAPURL = 'https://github.com/Electrical-Age/ElectricalAge/releases/download/BETA-1.11r51/ElectricalAge_tutorial_map-BETA-1.11r51.zip'
4 changes: 1 addition & 3 deletions src/main/java/mods/eln/Eln.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@

import static mods.eln.i18n.I18N.*;

@Mod(modid = Eln.MODID, name = Eln.NAME, version = Version.VERSION_STRING)
// @Mod(modid = "Eln", name = "Electrical Age", version = "BETA-1.2.0b")
// @NetworkMod(clientSideRequired = true, serverSideRequired = true, channels = { "miaouMod" }, packetHandler = PacketHandler.class)
@Mod(modid = Eln.MODID, name = Eln.NAME, version = "@VERSION@")
public class Eln {
// Mod information (override from 'mcmod.info' file)
public final static String MODID = "Eln";
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/mods/eln/misc/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
public final class Version {

/** Major version code. */
public final static int MAJOR = 1;
public final static int MAJOR = Integer.parseInt("@MAJORVERSION@");

/** Minor version code. */
public final static int MINOR = 12;
public final static int MINOR = Integer.parseInt("@MINORVERSION@");

/** Revision version code. */
public final static int REVISION = 0;
public final static int REVISION = Integer.parseInt("@REVISION@");

/**
* Unique version code. Must be a String for annotations. Used to check if a
Expand Down

5 comments on commit eac6d48

@cm0x4D
Copy link
Member

@cm0x4D cm0x4D commented on eac6d48 Nov 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this way I can not start the client and server directly from IntelliJ without starting (and wasting time) the external gradle task. @Baughn Do you start the server and client always using gradle?

@Baughn
Copy link
Contributor Author

@Baughn Baughn commented on eac6d48 Nov 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I use IntelliJ...

Did you try refreshing your gradle setup? This should still work from IDEA.

@cm0x4D
Copy link
Member

@cm0x4D cm0x4D commented on eac6d48 Nov 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I did, strange. Maybe I should try to delete IntelliJ's cache, but it is not really an issue...

@Baughn
Copy link
Contributor Author

@Baughn Baughn commented on eac6d48 Nov 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you were right, and it only worked for me for... some reason.

It's properly fixed now.

@cm0x4D
Copy link
Member

@cm0x4D cm0x4D commented on eac6d48 Nov 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. IDEA and its cache...

Please sign in to comment.