forked from squeek502/AppleCore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
146 lines (127 loc) · 3.94 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
buildscript {
repositories {
jcenter()
maven { url = "http://files.minecraftforge.net/maven" }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
minecraft {
version = minecraft_version + "-" + forge_version
mappings = mappings_version
runDir = "run"
coreMod = "squeek.applecore.AppleCore"
replace "\${version}", project.version
replace "\${apiversion}", api_version
replaceIn "ModInfo.java"
replaceIn "package-info.java"
}
group = project.projectDir.name.toLowerCase()
def modId = project.projectDir.name
archivesBaseName = modId + "-mc" + project.minecraft.version
if (version == "unspecified")
version = ""
if (System.getenv("TRAVIS_BUILD_NUMBER") != null)
version += (version ? "+" : "") + "${System.getenv("TRAVIS_BUILD_NUMBER").toInteger() + 230}"
if (System.getenv("TRAVIS_COMMIT") != null)
version += (version ? "." : "") + "${System.getenv("TRAVIS_COMMIT").take(5)}"
sourceSets.main{
java {
srcDirs 'java', 'apis'
}
resources {
srcDirs 'resources'
}
}
jar {
manifest {
attributes 'FMLCorePlugin': 'squeek.applecore.AppleCore'
attributes 'FMLCorePluginContainsFMLMod': 'true'
}
}
task deobfArtifact(type: Jar) {
from sourceSets.main.output
manifest = jar.manifest
classifier = 'deobf'
}
task apiArtifact(type: Jar, dependsOn: compileJava) {
from sourceSets.main.output
include "squeek/applecore/api/**"
classifier = 'api'
}
task sourcesArtifact(type: Jar, dependsOn: compileJava) {
from tasks.sourceMainJava.output
classifier = 'sources'
}
artifacts {
archives deobfArtifact
archives apiArtifact
archives sourcesArtifact
}
processResources {
inputs.property "vars", project.version + project.minecraft.version + api_version
from(sourceSets.main.resources.srcDirs) {
include '**/*.info'
expand 'version':project.version, 'mcversion':project.minecraft.version, 'apiversion':api_version
}
from(sourceSets.main.resources.srcDirs) {
exclude '**/*.info'
}
}
task removeExampleAndReferenceSources(type:Delete) {
delete += tasks.sourceMainJava.output.getPath()+"/squeek/applecore/example"
delete += tasks.sourceMainJava.output.getPath()+"/squeek/applecore/asm/reference"
}
task removeExampleAndReferenceResources(type:Delete) {
delete += file(sourceSets.main.output.resourcesDir.getPath()+"/mcmod.info")
}
// insert custom tasks
afterEvaluate { project ->
if (!project.hasProperty('buildexample'))
{
sourceMainJava.finalizedBy(removeExampleAndReferenceSources)
processResources.finalizedBy(removeExampleAndReferenceResources)
}
}
ext.mavenUrl = project.hasProperty('mavenUrl') ? mavenUrl : System.getenv("MAVEN_URL")
ext.mavenUser = project.hasProperty('mavenUser') ? mavenUser : System.getenv("MAVEN_USER")
ext.mavenPass = project.hasProperty('mavenPass') ? mavenPass : System.getenv("MAVEN_PASS")
def isPullRequest = System.getenv("TRAVIS_PULL_REQUEST") != null && System.getenv("TRAVIS_PULL_REQUEST") != false
def isCI = System.getenv("CI") == true
def isMainBranch = System.getenv("TRAVIS_BRANCH") == project.minecraft.version
def okayToPublish = !isCI || (!isPullRequest && isMainBranch)
if (mavenUrl && !project.hasProperty('nopublish') && okayToPublish) {
apply plugin: 'maven'
configurations {
deployerJars
}
dependencies {
deployerJars "org.apache.maven.wagon:wagon-webdav:1.0-beta-2"
}
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.deployerJars
pom.artifactId = modId
pom.version = project.minecraft.version + "-" + project.version
pom.project {
url = "https://github.com/squeek502/" + modId
}
repository(url: mavenUrl) {
authentication(userName: mavenUser, password: mavenPass)
}
}
}
afterEvaluate { project ->
build.finalizedBy(uploadArchives)
}
}
task testPom << {
apply plugin: 'maven'
pom {
whenConfigured {pom ->
//pom.dependencies.removeAll {dep -> dep.groupId == "squeek.asmhelper" }
}
}.writeTo(new PrintWriter(System.out))
}