|
| 1 | +// Default tasks |
| 2 | +defaultTasks 'clean', 'licenseFormat', 'build', 'install' |
| 3 | + |
| 4 | +// Apply plugins |
| 5 | +apply plugin: 'java' |
| 6 | +apply plugin: 'cobertura' // Coveralls dependency |
| 7 | +apply plugin: 'com.github.kt3k.coveralls' |
| 8 | +apply plugin: 'license' |
| 9 | +apply plugin: 'maven' |
| 10 | +apply plugin: 'signing' |
| 11 | + |
| 12 | +// Project information |
| 13 | +ext.projectName = 'Flow React' |
| 14 | +group = 'com.flowpowered' |
| 15 | +archivesBaseName = 'flow-react' |
| 16 | +version = '1.0.0-SNAPSHOT' |
| 17 | +ext.packaging = 'jar' |
| 18 | +ext.inceptionYear = '2013' |
| 19 | +ext.url = 'https://flowpowered.com/react' |
| 20 | +ext.description = 'Real-time 3D physics library for Java, based on the ReactPhysics3D library.' |
| 21 | + |
| 22 | +// Organization information |
| 23 | +ext.organization = 'Flow Powered' |
| 24 | +ext.organizationUrl = 'https://flowpowered.com' |
| 25 | + |
| 26 | +// Build properties |
| 27 | +ext.buildNumber = project.hasProperty('buildNumber') ? buildNumber : '0' |
| 28 | +ext.ciSystem = project.hasProperty('ciSystem') ? ciSystem : 'unknown' |
| 29 | +ext.commit = project.hasProperty('commit') ? commit : 'unknown' |
| 30 | + |
| 31 | +// Build plugin repositories and dependencies |
| 32 | +buildscript { |
| 33 | + repositories { |
| 34 | + mavenLocal() |
| 35 | + mavenCentral() |
| 36 | + maven { |
| 37 | + name = 'sonatype-nexus' |
| 38 | + url = 'https://oss.sonatype.org/content/groups/public/' |
| 39 | + } |
| 40 | + } |
| 41 | + dependencies { |
| 42 | + classpath 'net.saliman:gradle-cobertura-plugin:2.2.5' // Coveralls dependency |
| 43 | + classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.10.0' |
| 44 | + classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1' |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +// Project repositories |
| 49 | +repositories { |
| 50 | + mavenLocal() |
| 51 | + mavenCentral() |
| 52 | + maven { |
| 53 | + name = 'sonatype-nexus' |
| 54 | + url = 'https://oss.sonatype.org/content/groups/public/' |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +// Project dependencies |
| 59 | +dependencies { |
| 60 | + compile 'net.sf.trove4j:trove4j:3.0.3' |
| 61 | + testCompile 'junit:junit:4.12' |
| 62 | +} |
| 63 | + |
| 64 | +// Filter, process, and include resources |
| 65 | +processResources { |
| 66 | + // Include in final JAR |
| 67 | + from(rootProject.rootDir) { |
| 68 | + include 'LICENSE.txt' |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +// License header formatting |
| 73 | +license { |
| 74 | + ext.project = projectName |
| 75 | + ext.year = inceptionYear |
| 76 | + ext.name = organization |
| 77 | + ext.url = organizationUrl |
| 78 | + header rootProject.file('HEADER.txt') |
| 79 | + ignoreFailures true |
| 80 | + strictCheck true |
| 81 | + useDefaultMappings false |
| 82 | + mapping { java = 'SLASHSTAR_STYLE' } |
| 83 | +} |
| 84 | + |
| 85 | +// Source compiler configuration |
| 86 | +configure([compileJava, compileTestJava]) { |
| 87 | + sourceCompatibility = '1.7' |
| 88 | + targetCompatibility = '1.7' |
| 89 | + options.encoding = 'UTF-8' |
| 90 | + options.compilerArgs << '-Xlint:all' |
| 91 | + options.compilerArgs << '-Xlint:-path' |
| 92 | + options.deprecation = true |
| 93 | +} |
| 94 | + |
| 95 | +// JAR manifest configuration |
| 96 | +jar.manifest.mainAttributes( |
| 97 | + 'Built-By': System.properties['user.name'], |
| 98 | + 'Created-By': System.properties['java.vm.version'] + ' (' + System.properties['java.vm.vendor'] + ')', |
| 99 | + 'Specification-Title': projectName, |
| 100 | + 'Specification-Version': version + '+' + ciSystem + '-b' + buildNumber + '.git-' + commit, |
| 101 | + 'Specification-Vendor': organization + ' - ' + organizationUrl) |
| 102 | + |
| 103 | +// Javadoc doclint configuration |
| 104 | +if (JavaVersion.current().isJava8Compatible()) { |
| 105 | + allprojects { |
| 106 | + tasks.withType(Javadoc) { |
| 107 | + options.addStringOption('Xdoclint:none', '-quiet') |
| 108 | + } |
| 109 | + } |
| 110 | +} |
| 111 | + |
| 112 | +// Coveralls report configuration |
| 113 | +cobertura.coverageFormats = ['html', 'xml'] // Coveralls requires xml format |
| 114 | + |
| 115 | +// Artifact deployment |
| 116 | +uploadArchives { |
| 117 | + repositories.mavenDeployer { |
| 118 | + // Javadoc JAR generation |
| 119 | + task javadocJar(type: Jar, dependsOn: javadoc) { |
| 120 | + classifier = 'javadoc' |
| 121 | + from 'build/docs/javadoc' |
| 122 | + } |
| 123 | + |
| 124 | + // Source JAR generation |
| 125 | + task sourcesJar(type: Jar) { |
| 126 | + classifier = 'sources' |
| 127 | + from sourceSets.main.java.srcDirs |
| 128 | + } |
| 129 | + |
| 130 | + // Set all artifacts |
| 131 | + artifacts { |
| 132 | + archives jar, javadocJar, sourcesJar |
| 133 | + } |
| 134 | + |
| 135 | + // Tasks and variables based on if release or snapshot |
| 136 | + if (version.endsWith('-SNAPSHOT')) { |
| 137 | + // Set variable to snapshots repository URL |
| 138 | + ext.sonatypeUrl = 'https://oss.sonatype.org/content/repositories/snapshots/' |
| 139 | + } else { |
| 140 | + // Set variable to releases repository URL |
| 141 | + ext.sonatypeUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' |
| 142 | + |
| 143 | + // Artifact signing |
| 144 | + signing { |
| 145 | + // Sign JAR artifacts |
| 146 | + sign configurations.archives |
| 147 | + |
| 148 | + // Sign Maven POM |
| 149 | + beforeDeployment { |
| 150 | + org.gradle.api.artifacts.maven.MavenDeployment deployment -> signing.signPom(deployment) |
| 151 | + } |
| 152 | + } |
| 153 | + } |
| 154 | + |
| 155 | + // Set login credentials for repository |
| 156 | + repository(url: sonatypeUrl) { |
| 157 | + authentication(userName: System.getenv("sonatypeUsername"), password: System.getenv("sonatypePassword")) |
| 158 | + } |
| 159 | + |
| 160 | + // Maven POM generation |
| 161 | + pom.project { |
| 162 | + name projectName |
| 163 | + artifactId archivesBaseName |
| 164 | + packaging packaging |
| 165 | + inceptionYear inceptionYear |
| 166 | + url url |
| 167 | + description project.ext.description |
| 168 | + |
| 169 | + scm { |
| 170 | + connection 'scm:git:git://github.com/flow/react.git' |
| 171 | + developerConnection 'scm:git:ssh://[email protected]:flow/react.git' |
| 172 | + url 'https://github.com/flow/react' |
| 173 | + } |
| 174 | + |
| 175 | + licenses { |
| 176 | + license { |
| 177 | + name 'MIT License' |
| 178 | + url 'https://tldrlegal.com/l/mit' |
| 179 | + distribution 'repo' |
| 180 | + } |
| 181 | + } |
| 182 | + |
| 183 | + organization { |
| 184 | + name organization |
| 185 | + url organizationUrl |
| 186 | + } |
| 187 | + |
| 188 | + developers { |
| 189 | + developer { |
| 190 | + id 'DDoS' |
| 191 | + name 'Aleksi Sapon' |
| 192 | + |
| 193 | + } |
| 194 | + developer { |
| 195 | + id 'kitskub' |
| 196 | + name 'Jack Huey' |
| 197 | + |
| 198 | + } |
| 199 | + developer { |
| 200 | + id 'Wolf480pl' |
| 201 | + name 'Wolf480pl' |
| 202 | + |
| 203 | + } |
| 204 | + developer { |
| 205 | + id 'Wulfspider' |
| 206 | + name 'Luke Spragg' |
| 207 | + |
| 208 | + } |
| 209 | + } |
| 210 | + } |
| 211 | + } |
| 212 | +} |
0 commit comments