Skip to content

Commit 4365dbb

Browse files
stephan-ghChris Sanders
authored and
Chris Sanders
committed
Prepare Sponge for Project Unify. Closes SpongePowered#557.
Split build script into a common purpose build script.
1 parent ec7dff4 commit 4365dbb

11 files changed

+228
-199
lines changed

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Normalize as LF in the repository, OS native locally
22
* text=auto
3+
4+
*.bat text eol=crlf
5+
gradlew text eol=lf
6+
*.sh text eol=lf
7+
38
*.java text
9+
*.java diff=java
410

511
# Binary files that should not be modified
612
*.dat binary

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
sudo: false
2+
23
language: java
34
jdk:
45
- openjdk6
56
- openjdk7
67
- oraclejdk7
78
- oraclejdk8
9+
810
env: GRADLE_OPTS="-Xms1g -Xmx3g"
911
install: true
10-
script: gradle build
12+
script: ./gradlew build
13+
1114
notifications:
1215
email: false

HEADER.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
This file is part of Sponge, licensed under the MIT License (MIT).
1+
This file is part of ${name}, licensed under the MIT License (MIT).
22

3-
Copyright (c) SpongePowered.org <http://www.spongepowered.org>
3+
Copyright (c) ${organization} <${url}>
44
Copyright (c) contributors
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -19,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1919
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2020
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22-
THE SOFTWARE.
22+
THE SOFTWARE.

build.gradle

Lines changed: 6 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,17 @@
1-
// Gradle repositories and dependencies
21
buildscript {
32
repositories {
4-
mavenCentral()
53
jcenter()
64
}
5+
76
dependencies {
87
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0'
98
}
109
}
1110

12-
// Apply plugin
13-
apply plugin: 'java'
14-
apply plugin: 'license'
15-
apply plugin: 'checkstyle'
16-
apply plugin: 'maven'
17-
apply plugin: 'eclipse'
18-
apply plugin: 'idea'
19-
20-
// Default tasks
21-
defaultTasks 'licenseFormat', 'check', 'build'
22-
23-
// Basic project information
24-
group = 'org.spongepowered'
25-
archivesBaseName = 'spongeapi'
2611
version = '1.1-SNAPSHOT'
2712

28-
// Extended project information
29-
ext.projectName = 'SpongeAPI'
30-
ext.inceptionYear = '2014'
31-
ext.packaging = 'jar'
32-
ext.url = 'http://spongepowered.org'
33-
ext.description = 'SpongeAPI'
34-
ext.organization = 'SpongePowered'
35-
36-
// Define variables
37-
ext.buildNumber = project.hasProperty("buildNumber") ? buildNumber : '0'
38-
ext.ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown'
39-
ext.commit = project.hasProperty("commit") ? commit : 'unknown'
40-
41-
// Minimum version of Java required
42-
sourceCompatibility = '1.6'
43-
targetCompatibility = '1.6'
44-
45-
// Project repositories
46-
repositories {
47-
mavenCentral()
48-
49-
// Add Sponge repo for custom checkstyle implementation to fix some wrong warnings
50-
maven { url 'http://repo.spongepowered.org/maven' }
51-
}
52-
53-
configurations {
54-
deployerJars // maven stuff
55-
}
13+
ext.api = project
14+
apply from: 'gradle/java.gradle'
5615

5716
// Project dependencies
5817
dependencies {
@@ -63,150 +22,11 @@ dependencies {
6322
compile 'ninja.leaping.configurate:configurate-hocon:1.1'
6423
compile 'com.flowpowered:flow-math:1.0.0'
6524
compile 'org.ow2.asm:asm:5.0.3'
66-
testCompile 'junit:junit:4.11'
67-
testCompile 'org.hamcrest:hamcrest-library:1.3'
68-
testCompile 'org.mockito:mockito-core:1.9.0'
69-
70-
checkstyle 'org.spongepowered:checkstyle:6.1.1-sponge1'
71-
72-
// maven
73-
deployerJars 'org.apache.maven.wagon:wagon-ftp:2.7'
74-
}
75-
76-
// Filter, process, and include resources
77-
processResources {
78-
// Include in final JAR
79-
from 'LICENSE.txt'
80-
}
81-
82-
// License header formatting
83-
license {
84-
ext.name = project.name
85-
ext.organization = project.organization
86-
ext.url = project.url
87-
ext.year = project.inceptionYear
88-
exclude "**/*.info"
89-
exclude "assets/**"
90-
header file('HEADER.txt')
91-
sourceSets = project.sourceSets
92-
ignoreFailures false
93-
strictCheck true
94-
mapping {
95-
java = 'SLASHSTAR_STYLE'
96-
}
97-
}
98-
99-
test {
100-
testLogging {
101-
exceptionFormat = 'full'
102-
}
103-
}
104-
105-
checkstyle {
106-
configFile = file('checkstyle.xml')
107-
configProperties = [
108-
"name": project.name,
109-
"organization": project.organization,
110-
"url": project.url,
111-
"year": project.inceptionYear,
112-
"basedir": project.projectDir,
113-
"severity": 'warning'
114-
]
115-
}
116-
117-
// Source compiler configuration
118-
configure([compileJava, compileTestJava]) {
119-
options.compilerArgs += ['-Xlint:all', '-Xlint:-path']
120-
options.deprecation = true
121-
options.encoding = 'utf8'
122-
}
123-
124-
javadoc {
125-
options.jFlags('-Xms256m', '-Xmx512m')
126-
options.links("http://docs.guava-libraries.googlecode.com/git-history/v17.0/javadoc/",
127-
"http://google.github.io/guice/api-docs/latest/javadoc/",
128-
"http://flowpowered.com/math/",
129-
"http://asm.ow2.org/asm50/javadoc/user/",
130-
"http://www.slf4j.org/apidocs/",
131-
"http://docs.oracle.com/javase/6/docs/api/")
132-
}
133-
134-
if (JavaVersion.current().isJava8Compatible()) {
135-
tasks.withType(Javadoc) {
136-
// disable the crazy super-strict doclint tool in Java 8
137-
options.addStringOption('Xdoclint:none', '-quiet')
138-
}
13925
}
14026

14127
// JAR manifest configuration
142-
jar.manifest.mainAttributes(
143-
"Built-By": System.properties['user.name'],
144-
"Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
145-
"Implementation-Title": name,
146-
"Implementation-Version": version + "+" + ciSystem + "-b" + buildNumber + ".git-" + commit,
147-
"Implementation-Vendor": url,
148-
"Main-Class": "org.spongepowered.api.util.InformativeMain")
149-
150-
task sourceJar(type: Jar) {
151-
from sourceSets.main.java
152-
from sourceSets.main.resources
153-
classifier = "sources"
154-
}
155-
156-
task javadocJar(type: Jar, dependsOn: javadoc) {
157-
from javadoc.destinationDir
158-
classifier = "javadoc"
159-
}
160-
161-
artifacts {
162-
archives jar
163-
archives sourceJar
164-
archives javadocJar
165-
}
166-
167-
uploadArchives {
168-
repositories {
169-
170-
mavenDeployer {
171-
configuration = configurations.deployerJars
172-
173-
if (project.hasProperty("chRepo"))
174-
{
175-
repository(url: project.chRepo) {
176-
authentication(userName: project.chUsername, password: project.chPassword)
177-
}
178-
}
179-
180-
pom {
181-
groupId = project.group
182-
version = project.version
183-
artifactId = project.archivesBaseName
184-
project {
185-
name project.archivesBaseName
186-
packaging 'jar'
187-
description 'Sponge API'
188-
url 'http://www.spongepowered.org/'
189-
190-
scm {
191-
url 'https://github.com/SpongePowered/SpongeAPI'
192-
connection 'scm:git:git://github.com/SpongePowered/SpongeAPI.git'
193-
developerConnection 'scm:git:[email protected]:SpongePowered/SpongeAPI.git'
194-
}
195-
196-
issueManagement {
197-
system 'youtrack'
198-
url 'https://issues.spongepowered.org/'
199-
}
200-
201-
licenses {
202-
license {
203-
name 'MIT license'
204-
url 'http://opensource.org/licenses/MIT'
205-
distribution 'repo'
206-
}
207-
}
208-
}
209-
}
210-
}
28+
jar {
29+
manifest {
30+
attributes('Main-Class': 'org.spongepowered.api.util.InformativeMain')
21131
}
21232
}

checkstyle.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220

221221
<module name="NewlineAtEndOfFile"/>
222222
<module name="SuppressionFilter">
223-
<property name="file" value="${basedir}/checkstyle-suppressions.xml"/>
223+
<property name="file" value="${suppressions}"/>
224224
</module>
225225

226226
<property name="basedir" value="${basedir}"/>

gradle.properties

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
theName=SpongeAPI
2-
inceptionYear=2014
3-
packaging=jar
4-
url=http://spongepowered.org
5-
description=SpongeAPI
1+
name=SpongeAPI
2+
description=A Minecraft plugin API
3+
url=https://www.spongepowered.org
64
organization=SpongePowered

gradle/deploy.gradle

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
apply plugin: 'maven'
2+
3+
ext {
4+
buildNumber = System.getenv().BUILD_NUMBER != null ? System.getenv().BUILD_NUMBER : '0'
5+
ciSystem = System.getenv().ciSystem != null ? System.getenv().ciSystem : 'unknown'
6+
commit = System.getenv().commit != null ? System.getenv().commit : 'unknown'
7+
}
8+
9+
configurations {
10+
deployerJars // Deployment dependency
11+
}
12+
13+
dependencies {
14+
deployerJars 'org.apache.maven.wagon:wagon-ftp:2.8'
15+
}
16+
17+
uploadArchives {
18+
repositories {
19+
mavenDeployer {
20+
configuration = configurations.deployerJars
21+
22+
if (project.hasProperty('chRepo')) {
23+
repository(url: project.chRepo) {
24+
authentication(userName: project.chUsername, password: project.chPassword)
25+
}
26+
}
27+
28+
pom {
29+
groupId = project.group
30+
artifactId = project.archivesBaseName
31+
version = project.version
32+
33+
project {
34+
name project.archivesBaseName
35+
description project.description
36+
packaging 'jar'
37+
url project.url
38+
39+
scm {
40+
url "https://github.com/$project.organization/$project.name"
41+
connection "scm:git:https://github.com/$project.organization/${project.name}.git"
42+
developerConnection "scm:git:[email protected]:$project.organization/${project.name}.git"
43+
}
44+
45+
issueManagement {
46+
system 'youtrack'
47+
url 'https://issues.spongepowered.org'
48+
}
49+
50+
licenses {
51+
license {
52+
name 'MIT License'
53+
url 'http://opensource.org/licenses/MIT'
54+
distribution 'repo'
55+
}
56+
}
57+
}
58+
}
59+
}
60+
}
61+
}

0 commit comments

Comments
 (0)