diff --git a/.gitattributes b/.gitattributes index d429d269b..1a45d083e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,12 @@ # Normalize as LF in the repository, OS native locally * text=auto + +*.bat text eol=crlf +gradlew text eol=lf +*.sh text eol=lf + *.java text +*.java diff=java # Binary files that should not be modified *.dat binary diff --git a/.travis.yml b/.travis.yml index 79a3a9c58..0ebed3956 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,15 @@ sudo: false + language: java jdk: - openjdk6 - openjdk7 - oraclejdk7 - oraclejdk8 + env: GRADLE_OPTS="-Xms1g -Xmx3g" install: true -script: gradle build +script: ./gradlew build + notifications: email: false diff --git a/HEADER.txt b/HEADER.txt index be04201cd..222ce42ee 100644 --- a/HEADER.txt +++ b/HEADER.txt @@ -1,6 +1,6 @@ -This file is part of Sponge, licensed under the MIT License (MIT). +This file is part of ${name}, licensed under the MIT License (MIT). -Copyright (c) SpongePowered.org +Copyright (c) ${organization} <${url}> Copyright (c) contributors 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/build.gradle b/build.gradle index 45b845586..a37c06b55 100644 --- a/build.gradle +++ b/build.gradle @@ -1,58 +1,17 @@ -// Gradle repositories and dependencies buildscript { repositories { - mavenCentral() jcenter() } + dependencies { classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0' } } -// Apply plugin -apply plugin: 'java' -apply plugin: 'license' -apply plugin: 'checkstyle' -apply plugin: 'maven' -apply plugin: 'eclipse' -apply plugin: 'idea' - -// Default tasks -defaultTasks 'licenseFormat', 'check', 'build' - -// Basic project information -group = 'org.spongepowered' -archivesBaseName = 'spongeapi' version = '1.1-SNAPSHOT' -// Extended project information -ext.projectName = 'SpongeAPI' -ext.inceptionYear = '2014' -ext.packaging = 'jar' -ext.url = 'http://spongepowered.org' -ext.description = 'SpongeAPI' -ext.organization = 'SpongePowered' - -// Define variables -ext.buildNumber = project.hasProperty("buildNumber") ? buildNumber : '0' -ext.ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown' -ext.commit = project.hasProperty("commit") ? commit : 'unknown' - -// Minimum version of Java required -sourceCompatibility = '1.6' -targetCompatibility = '1.6' - -// Project repositories -repositories { - mavenCentral() - - // Add Sponge repo for custom checkstyle implementation to fix some wrong warnings - maven { url 'http://repo.spongepowered.org/maven' } -} - -configurations { - deployerJars // maven stuff -} +ext.api = project +apply from: 'gradle/java.gradle' // Project dependencies dependencies { @@ -63,150 +22,11 @@ dependencies { compile 'ninja.leaping.configurate:configurate-hocon:1.1' compile 'com.flowpowered:flow-math:1.0.0' compile 'org.ow2.asm:asm:5.0.3' - testCompile 'junit:junit:4.11' - testCompile 'org.hamcrest:hamcrest-library:1.3' - testCompile 'org.mockito:mockito-core:1.9.0' - - checkstyle 'org.spongepowered:checkstyle:6.1.1-sponge1' - - // maven - deployerJars 'org.apache.maven.wagon:wagon-ftp:2.7' -} - -// Filter, process, and include resources -processResources { - // Include in final JAR - from 'LICENSE.txt' -} - -// License header formatting -license { - ext.name = project.name - ext.organization = project.organization - ext.url = project.url - ext.year = project.inceptionYear - exclude "**/*.info" - exclude "assets/**" - header file('HEADER.txt') - sourceSets = project.sourceSets - ignoreFailures false - strictCheck true - mapping { - java = 'SLASHSTAR_STYLE' - } -} - -test { - testLogging { - exceptionFormat = 'full' - } -} - -checkstyle { - configFile = file('checkstyle.xml') - configProperties = [ - "name": project.name, - "organization": project.organization, - "url": project.url, - "year": project.inceptionYear, - "basedir": project.projectDir, - "severity": 'warning' - ] -} - -// Source compiler configuration -configure([compileJava, compileTestJava]) { - options.compilerArgs += ['-Xlint:all', '-Xlint:-path'] - options.deprecation = true - options.encoding = 'utf8' -} - -javadoc { - options.jFlags('-Xms256m', '-Xmx512m') - options.links("http://docs.guava-libraries.googlecode.com/git-history/v17.0/javadoc/", - "http://google.github.io/guice/api-docs/latest/javadoc/", - "http://flowpowered.com/math/", - "http://asm.ow2.org/asm50/javadoc/user/", - "http://www.slf4j.org/apidocs/", - "http://docs.oracle.com/javase/6/docs/api/") -} - -if (JavaVersion.current().isJava8Compatible()) { - tasks.withType(Javadoc) { - // disable the crazy super-strict doclint tool in Java 8 - options.addStringOption('Xdoclint:none', '-quiet') - } } // JAR manifest configuration -jar.manifest.mainAttributes( - "Built-By": System.properties['user.name'], - "Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")", - "Implementation-Title": name, - "Implementation-Version": version + "+" + ciSystem + "-b" + buildNumber + ".git-" + commit, - "Implementation-Vendor": url, - "Main-Class": "org.spongepowered.api.util.InformativeMain") - -task sourceJar(type: Jar) { - from sourceSets.main.java - from sourceSets.main.resources - classifier = "sources" -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - from javadoc.destinationDir - classifier = "javadoc" -} - -artifacts { - archives jar - archives sourceJar - archives javadocJar -} - -uploadArchives { - repositories { - - mavenDeployer { - configuration = configurations.deployerJars - - if (project.hasProperty("chRepo")) - { - repository(url: project.chRepo) { - authentication(userName: project.chUsername, password: project.chPassword) - } - } - - pom { - groupId = project.group - version = project.version - artifactId = project.archivesBaseName - project { - name project.archivesBaseName - packaging 'jar' - description 'Sponge API' - url 'http://www.spongepowered.org/' - - scm { - url 'https://github.com/SpongePowered/SpongeAPI' - connection 'scm:git:git://github.com/SpongePowered/SpongeAPI.git' - developerConnection 'scm:git:git@github.com:SpongePowered/SpongeAPI.git' - } - - issueManagement { - system 'youtrack' - url 'https://issues.spongepowered.org/' - } - - licenses { - license { - name 'MIT license' - url 'http://opensource.org/licenses/MIT' - distribution 'repo' - } - } - } - } - } +jar { + manifest { + attributes('Main-Class': 'org.spongepowered.api.util.InformativeMain') } } diff --git a/checkstyle.xml b/checkstyle.xml index b394c6671..0b97b8550 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -220,7 +220,7 @@ - + diff --git a/gradle.properties b/gradle.properties index 97a77613a..0d2478a1c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,4 @@ -theName=SpongeAPI -inceptionYear=2014 -packaging=jar -url=http://spongepowered.org -description=SpongeAPI +name=SpongeAPI +description=A Minecraft plugin API +url=https://www.spongepowered.org organization=SpongePowered diff --git a/gradle/deploy.gradle b/gradle/deploy.gradle new file mode 100644 index 000000000..56fbb17e2 --- /dev/null +++ b/gradle/deploy.gradle @@ -0,0 +1,61 @@ +apply plugin: 'maven' + +ext { + buildNumber = System.getenv().BUILD_NUMBER != null ? System.getenv().BUILD_NUMBER : '0' + ciSystem = System.getenv().ciSystem != null ? System.getenv().ciSystem : 'unknown' + commit = System.getenv().commit != null ? System.getenv().commit : 'unknown' +} + +configurations { + deployerJars // Deployment dependency +} + +dependencies { + deployerJars 'org.apache.maven.wagon:wagon-ftp:2.8' +} + +uploadArchives { + repositories { + mavenDeployer { + configuration = configurations.deployerJars + + if (project.hasProperty('chRepo')) { + repository(url: project.chRepo) { + authentication(userName: project.chUsername, password: project.chPassword) + } + } + + pom { + groupId = project.group + artifactId = project.archivesBaseName + version = project.version + + project { + name project.archivesBaseName + description project.description + packaging 'jar' + url project.url + + scm { + url "https://github.com/$project.organization/$project.name" + connection "scm:git:https://github.com/$project.organization/${project.name}.git" + developerConnection "scm:git:git@github.com:$project.organization/${project.name}.git" + } + + issueManagement { + system 'youtrack' + url 'https://issues.spongepowered.org' + } + + licenses { + license { + name 'MIT License' + url 'http://opensource.org/licenses/MIT' + distribution 'repo' + } + } + } + } + } + } +} diff --git a/gradle/java.gradle b/gradle/java.gradle new file mode 100644 index 000000000..3c4517a48 --- /dev/null +++ b/gradle/java.gradle @@ -0,0 +1,141 @@ +apply plugin: 'java' +apply plugin: 'eclipse' +apply plugin: 'idea' + +defaultTasks 'licenseFormat', 'build' + +group = 'org.spongepowered' +archivesBaseName = project.name.toLowerCase() + +// Java version +sourceCompatibility = '1.6' +targetCompatibility = '1.6' + +repositories { + mavenCentral() + maven { + name = 'sponge' + url = 'http://repo.spongepowered.org/maven' + } +} + +// Testing dependencies +dependencies { + testCompile 'junit:junit:4.12' + testCompile 'org.hamcrest:hamcrest-library:1.3' + testCompile 'org.mockito:mockito-core:1.10.19' +} + +// Source compiler configuration +configure([compileJava, compileTestJava]) { + options.compilerArgs += ['-Xlint:all', '-Xlint:-path'] + options.deprecation = true + options.encoding = 'UTF-8' +} + +test { + testLogging { + exceptionFormat = 'full' + } +} + +// Set manifest entries +jar { + manifest { + attributes( + 'Built-By': System.properties['user.name'], + 'Created-By': "${System.properties['java.vm.version']} (${System.properties['java.vm.vendor']})", + 'Implementation-Name': project.name, + 'Implementation-Version': project.version, + 'Implementation-Vendor': project.url + ) + } +} + +javadoc { + options.encoding = 'UTF-8' + options.charSet = 'UTF-8' + options.jFlags('-Xms256m', '-Xmx512m') + options.links( + 'http://www.slf4j.org/apidocs/', + 'http://docs.guava-libraries.googlecode.com/git-history/v17.0/javadoc/', + 'http://google.github.io/guice/api-docs/latest/javadoc/', + /*'http://zachsthings.com/configurate/configurate-core/apidocs/', + 'http://zachsthings.com/configurate/configurate-hocon/apidocs/',*/ + 'http://flowpowered.com/math/', + 'http://asm.ow2.org/asm50/javadoc/user/', + 'http://docs.oracle.com/javase/6/docs/api/' + ) +} + +if (JavaVersion.current().isJava8Compatible()) { + tasks.withType(Javadoc) { + // Disable the crazy super-strict doclint tool in Java 8 + options.addStringOption('Xdoclint:none', '-quiet') + } +} + +task sourceJar(type: Jar) { + classifier = 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives sourceJar + archives javadocJar +} + +// Apply code style plugins +apply plugin: 'license' +apply plugin: 'checkstyle' + +// License header formatting +license { + ext { + name = project.name + organization = project.organization + url = project.url + } + + header api.file('HEADER.txt') + include '**/*.java' + + ignoreFailures false + strictCheck true + + mapping { + java = 'SLASHSTAR_STYLE' + } +} + +processResources { + // Include in final JAR + from 'LICENSE.txt' +} + +dependencies { + // Add custom checkstyle dependency (fixes a few wrong warnings about imports and @param tags in annotations) + checkstyle 'org.spongepowered:checkstyle:6.1.1-sponge1' +} + +// Checkstyle settings +checkstyle { + configFile = api.file('checkstyle.xml') + configProperties = [ + 'basedir': project.projectDir, + 'suppressions': project.file('checkstyle-suppressions.xml'), + 'severity': 'warning' + ] +} + +// Deployment configuration +apply from: api.file('gradle/deploy.gradle') + +task wrapper(type: Wrapper) { + gradleVersion = '2.3' +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 667288ad6..085a1cdc2 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 61999ed57..623289704 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat May 03 12:44:05 CDT 2014 +#Fri Apr 03 11:08:44 CEST 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=http\://services.gradle.org/distributions/gradle-2.0-all.zip \ No newline at end of file +distributionUrl=http\://services.gradle.org/distributions/gradle-2.3-bin.zip diff --git a/settings.gradle b/settings.gradle index a809ba952..89f411069 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -rootProject.name = theName +rootProject.name = name