Updated build scripts to kotlin

This commit is contained in:
nathan 2019-01-12 23:59:52 +01:00
parent 4d1afe4703
commit e033a52823
4 changed files with 403 additions and 330 deletions

View File

@ -14,504 +14,577 @@
* limitations under the License. * limitations under the License.
*/ */
import Build_gradle.Extras.bcVersion
import java.nio.file.Paths import java.nio.file.Paths
import java.time.Instant import java.time.Instant
import java.util.Properties
buildscript { import kotlin.reflect.full.declaredMemberProperties
// load properties from custom location import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
def propsFile = Paths.get("${projectDir}/../../gradle.properties").normalize().toFile() import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
if (propsFile.canRead()) { import org.jetbrains.kotlin.backend.common.onlyIf
println("Loading custom property data from: ${propsFile}")
def props = new Properties()
propsFile.withInputStream {props.load(it)}
props.each {key, val -> project.ext.set(key, val)}
}
else {
ext.sonatypeUsername = ""
ext.sonatypePassword = ""
}
// for plugin publishing and license sources
repositories {
maven {url "https://plugins.gradle.org/m2/"}
}
dependencies {
// this is the only way to also get the source code for IDE auto-complete
classpath "gradle.plugin.com.dorkbox:Licensing:1.3"
classpath "gradle.plugin.com.dorkbox:Licensing:1.3:sources"
}
}
plugins { plugins {
id 'java' java
id 'maven-publish' signing
id 'signing' `maven-publish`
// close and release on sonatype // close and release on sonatype
id 'io.codearte.nexus-staging' version '0.20.0' id("io.codearte.nexus-staging") version "0.20.0"
id "com.dorkbox.CrossCompile" version "1.0.1" id("com.dorkbox.CrossCompile") version "1.0.1"
id "com.dorkbox.VersionUpdate" version "1.4" id("com.dorkbox.Licensing") version "1.4"
id("com.dorkbox.VersionUpdate") version "1.4.1"
// setup checking for the latest version of a plugin or dependency (and updating the gradle build) // setup checking for the latest version of a plugin or dependency
id "se.patrikerdes.use-latest-versions" version "0.2.3" id("com.github.ben-manes.versions") version "0.20.0"
kotlin("jvm") version "1.3.11"
} }
// this is the only way to also get the source code for IDE auto-complete
apply plugin: "com.dorkbox.Licensing"
// give us access to api/implementation differences for building java libraries println("Gradle ${project.gradle.gradleVersion}")
apply plugin: 'java-library'
project.description = 'Encrypted, high-performance, and event-driven/reactive network stack for Java 6+' // load properties from custom location
project.group = 'com.dorkbox' val propsFile = File("$projectDir/../../gradle.properties").normalize()
project.version = '2.13' if (propsFile.canRead()) {
println("Loading custom property data from: [$propsFile]")
project.ext.name = 'Network' val props = Properties()
project.ext.url = 'https://git.dorkbox.com/dorkbox/Network' props.load(propsFile.inputStream())
props.forEach { (k, v) -> project.extra.set(k as String, v as String) }
}
sourceCompatibility = 1.8
targetCompatibility = 1.8 object Extras {
// set for the project
const val description = "Encrypted, high-performance, and event-driven/reactive network stack for Java 6+"
const val group = "com.dorkbox"
const val version = "2.13"
// set as project.ext
const val name = "Network"
const val id = "Network"
const val vendor = "Dorkbox LLC"
const val url = "https://git.dorkbox.com/dorkbox/Network"
val buildDate = Instant.now().toString()
val JAVA_VERSION = JavaVersion.VERSION_1_6.toString()
val bcVersion = "1.60"
var sonatypeUsername = ""
var sonatypePassword = ""
}
///////////////////////////////
///// assign 'Extras' to project or project.ext
///////////////////////////////
description = Extras.description
group = Extras.group
version = Extras.version
Extras::class.declaredMemberProperties.forEach {
if (!project.hasProperty(it.name)) {
when {
it.isConst -> project.extra.set(it.name, it.getter.call())
else -> project.extra.set(it.name, it.getter.call(Extras::class.objectInstance))
}
}
}
// assign sonatype info if present
Extras.sonatypeUsername = project.extra["sonatypeUsername"] as String
Extras.sonatypePassword = project.extra["sonatypePassword"] as String
licensing { licensing {
license(License.APACHE_2) { license(License.APACHE_2) {
author 'dorkbox, llc' author(Extras.vendor)
url project.ext.url url(Extras.url)
note project.description note(Extras.description)
} }
license('Dorkbox Utils', License.APACHE_2) { license("Dorkbox Utils", License.APACHE_2) {
author 'dorkbox, llc' author(Extras.vendor)
url 'https://git.dorkbox.com/dorkbox/Utilities' url("https://git.dorkbox.com/dorkbox/Utilities")
} }
license('Bennidi Iterator', License.MIT) { license("Bennidi Iterator", License.MIT) {
copyright 2012 copyright(2012)
author 'Benjamin Diedrichsen' author("Benjamin Diedrichsen")
url 'https://github.com/bennidi/mbassador' url("https://github.com/bennidi/mbassador")
note 'Fast iterators from the MBassador project' note("Fast iterators from the MBassador project")
} }
license('BouncyCastle', License.MIT) { license("BouncyCastle", License.MIT) {
copyright 2009 copyright(2009)
author 'The Legion Of The Bouncy Castle' author("The Legion Of The Bouncy Castle")
url 'http://www.bouncycastle.org' url("http://www.bouncycastle.org")
} }
license('ObjectPool', License.APACHE_2) { license("ObjectPool", License.APACHE_2) {
author 'dorkbox, llc' author("dorkbox, llc")
url 'https://git.dorkbox.com/dorkbox/ObjectPool' url("https://git.dorkbox.com/dorkbox/ObjectPool")
} }
license('FastThreadLocal', License.BSD_3) { license("FastThreadLocal", License.BSD_3) {
copyright 2014 copyright(2014)
author 'Lightweight Java Game Library Project' author("Lightweight Java Game Library Project")
author 'Riven' author("Riven")
url 'https://github.com/LWJGL/lwjgl3/blob/5819c9123222f6ce51f208e022cb907091dd8023/modules/core/src/main/java/org/lwjgl/system/FastThreadLocal.java' url("https://github.com/LWJGL/lwjgl3/blob/5819c9123222f6ce51f208e022cb907091dd8023/modules/core/src/main/java/org/lwjgl/system/FastThreadLocal.java")
} }
license('Javassist', License.BSD_3) { license("Javassist", License.BSD_3) {
copyright 1999 copyright(1999)
author 'Shigeru Chiba' author("Shigeru Chiba")
author 'Bill Burke' author("Bill Burke")
author 'Jason T. Greene' author("Jason T. Greene")
url 'http://www.csg.is.titech.ac.jp/~chiba/java' url("http://www.csg.is.titech.ac.jp/~chiba/java")
note 'Licensed under the MPL/LGPL/Apache triple license' note("Licensed under the MPL/LGPL/Apache triple license")
} }
license('Kryo', License.BSD_3) { license("Kryo", License.BSD_3) {
copyright 2008 copyright(2008)
author 'Nathan Sweet' author("Nathan Sweet")
url 'https://github.com/EsotericSoftware/kryo' url("https://github.com/EsotericSoftware/kryo")
} }
license('kryo-serializers', License.APACHE_2) { license("kryo-serializers", License.APACHE_2) {
copyright 2010 copyright(2010)
author 'Martin Grotzke' author("Martin Grotzke")
author 'Rafael Winterhalter' author("Rafael Winterhalter")
url 'https://github.com/magro/kryo-serializers' url("https://github.com/magro/kryo-serializers")
} }
license('KryoNet RMI', License.BSD_3) { license("KryoNet RMI", License.BSD_3) {
copyright 2008 copyright(2008)
author 'Nathan Sweet' author("Nathan Sweet")
url 'https://github.com/EsotericSoftware/kryonet' url("https://github.com/EsotericSoftware/kryonet")
} }
license('LAN HostDiscovery from Apache Commons JCS', License.APACHE_2) { license("LAN HostDiscovery from Apache Commons JCS", License.APACHE_2) {
copyright 2014 copyright(2014)
author 'The Apache Software Foundation' author("The Apache Software Foundation")
url 'https://issues.apache.org/jira/browse/JCS-40' url("https://issues.apache.org/jira/browse/JCS-40")
} }
license('LZ4 and XXhash', License.APACHE_2) { license("LZ4 and XXhash", License.APACHE_2) {
copyright 2011 copyright(2011)
copyright 2012 copyright(2012)
author 'Yann Collet' author("Yann Collet")
author 'Adrien Grand' author("Adrien Grand")
url 'https://github.com/jpountz/lz4-java' url("https://github.com/jpountz/lz4-java")
} }
license('MathUtils, IntArray, IntMap', License.APACHE_2) { license("MathUtils, IntArray, IntMap", License.APACHE_2) {
copyright 2013 copyright(2013)
author 'Mario Zechner <badlogicgames@gmail.com>' author("Mario Zechner <badlogicgames@gmail.com>")
author 'Nathan Sweet <nathan.sweet@gmail.com>' author("Nathan Sweet <nathan.sweet@gmail.com>")
url 'http://github.com/libgdx/libgdx/' url("http://github.com/libgdx/libgdx/")
} }
license('MinLog-SLF4J', License.APACHE_2) { license("MinLog-SLF4J", License.APACHE_2) {
copyright 2008 copyright(2008)
author 'dorkbox, llc' author("dorkbox, llc")
author 'Nathan Sweet' author("Nathan Sweet")
author 'Dan Brown' author("Dan Brown")
url 'https://git.dorkbox.com/dorkbox/MinLog-SLF4J' url("https://git.dorkbox.com/dorkbox/MinLog-SLF4J")
url 'https://github.com/EsotericSoftware/minlog' url("https://github.com/EsotericSoftware/minlog")
note 'Drop-in replacement for MinLog to log through SLF4j.' note("Drop-in replacement for MinLog to log through SLF4j.")
} }
license('ReflectASM', License.BSD_3) { license("ReflectASM", License.BSD_3) {
copyright 2008 copyright(2008)
author 'Nathan Sweet' author("Nathan Sweet")
url 'https://github.com/EsotericSoftware/reflectasm' url("https://github.com/EsotericSoftware/reflectasm")
} }
license('SLF4J', License.MIT) { license("SLF4J", License.MIT) {
copyright 2008 copyright(2008)
author 'QOS.ch' author("QOS.ch")
url 'http://www.slf4j.org' url("http://www.slf4j.org")
} }
license('TypeTools', License.APACHE_2) { license("TypeTools", License.APACHE_2) {
copyright 2017 copyright(2017)
author 'Jonathan Halterman' author("Jonathan Halterman")
url 'https://github.com/jhalterman/typetools/' url("https://github.com/jhalterman/typetools/")
note 'Tools for resolving generic types' note("Tools for resolving generic types")
}
license('XBill DNS', License.BSD_3) {
copyright 2005
author 'Brian Wellington'
url 'http://www.xbill.org/dnsjava'
} }
} }
sourceSets { sourceSets {
main { main {
java { java {
setSrcDirs Collections.singletonList('src') setSrcDirs(listOf("src"))
// want to include java files for the source. 'setSrcDirs' resets includes...
include("**/*.java")
} }
} }
test { test {
java { java {
setSrcDirs Collections.singletonList('test') setSrcDirs(listOf("test"))
}
}
}
// want to include java files for the source. 'setSrcDirs' resets includes...
include("**/*.java")
}
}
}
repositories { repositories {
mavenLocal() // this must be first!
jcenter() jcenter()
} }
ext {
bcVersion = '1.60'
}
dependencies { dependencies {
implementation(project('Utilities')) { implementation(project("Utilities")) {
// don't include any of the project dependencies for anything // don't include any of the project dependencies for anything
transitive = false isTransitive = false
} }
// our main dependencies are ALSO the same as the limited utilities (they are not automatically pulled in from other sourceSets) // our main dependencies are ALSO the same as the limited utilities (they are not automatically pulled in from other sourceSets)
// needed by the utilities (custom since we don't want to include everything). IntelliJ includes everything, but our builds do not // needed by the utilities (custom since we don't want to include everything). IntelliJ includes everything, but our builds do not
api 'net.java.dev.jna:jna:4.5.2' api("io.netty:netty-all:4.1.32.Final")
api 'net.java.dev.jna:jna-platform:4.5.2' api("com.esotericsoftware:kryo:4.0.2")
api("net.jpountz.lz4:lz4:1.3.0")
api 'io.netty:netty-all:4.1.22.Final' api("org.bouncycastle:bcprov-jdk15on:$bcVersion")
api 'com.esotericsoftware:kryo:4.0.2' api("org.bouncycastle:bcpg-jdk15on:$bcVersion")
api 'net.jpountz.lz4:lz4:1.3.0' api("org.bouncycastle:bcmail-jdk15on:$bcVersion")
api("org.bouncycastle:bctls-jdk15on:$bcVersion")
api "org.bouncycastle:bcprov-jdk15on:$bcVersion"
api "org.bouncycastle:bcpg-jdk15on:$bcVersion"
api "org.bouncycastle:bcmail-jdk15on:$bcVersion"z
api "org.bouncycastle:bctls-jdk15on:$bcVersion"
api "com.dorkbox:ObjectPool:2.11" api("com.dorkbox:ObjectPool:2.11")
api 'org.slf4j:slf4j-api:1.7.25' implementation ("org.slf4j:slf4j-api:1.7.25")
testCompile 'junit:junit:4.12' testCompile("junit:junit:4.12")
testCompile ("ch.qos.logback:logback-classic:1.1.6") testCompile("ch.qos.logback:logback-classic:1.2.3")
} }
project("Utilities") {
project('Utilities') { tasks.withType<Test> {
tasks.withType(Test) {
// want to remove utilities project from unit tests. It's unnecessary to run unit tests for the entire Utilities project // want to remove utilities project from unit tests. It's unnecessary to run unit tests for the entire Utilities project
exclude('**/*') exclude("**/*")
} }
tasks.withType(JavaCompile) { tasks.withType<JavaCompile> {
options.encoding = 'UTF-8' options.encoding = "UTF-8"
options.incremental = true options.isIncremental = true
}
}
// setup compile options. we specifically want to suppress usage of "Unsafe"
options.compilerArgs = ['-XDignore.symbol.file', '-Xlint:deprecation']
}
}
/////////////////////////////// ///////////////////////////////
////// Task defaults ////// Task defaults
/////////////////////////////// ///////////////////////////////
tasks.withType(JavaCompile) { tasks.withType<JavaCompile> {
options.encoding = 'UTF-8' options.encoding = "UTF-8"
sourceCompatibility = Extras.JAVA_VERSION
targetCompatibility = Extras.JAVA_VERSION
} }
tasks.withType(Jar) { tasks.withType<Jar> {
duplicatesStrategy DuplicatesStrategy.FAIL duplicatesStrategy = DuplicatesStrategy.FAIL
}
manifest {
attributes['Implementation-Version'] = version
attributes['Build-Date'] = Instant.now().toString()
}
}
/////////////////////////////// ///////////////////////////////
////// UTILITIES COMPILE (for inclusion into jars) ////// UTILITIES COMPILE (for inclusion into jars)
/////////////////////////////// ///////////////////////////////
static String[] javaFile(String... fileNames) { fun javaFile(vararg fileNames: String): Iterable<String> {
def fileList = [] as ArrayList val fileList = ArrayList<String>()
for (name in fileNames) { fileNames.forEach { name ->
def fixed = name.replace('.', '/') + '.java' fileList.add(name.replace('.', '/') + ".java")
fileList.add(fixed)
} }
return fileList return fileList
} }
task compileUtils(type: JavaCompile) { task<JavaCompile>("compileUtils") {
// we don't want the default include of **/*.java // we don't want the default include of **/*.java
getIncludes().clear() includes.clear()
source = Collections.singletonList('../Utilities/src') source = fileTree("../Utilities/src")
include javaFile('dorkbox.util.OS', include(javaFile(
'dorkbox.util.OSType', "dorkbox.util.OS",
'dorkbox.util.Property', "dorkbox.util.OSType",
'dorkbox.util.NamedThreadFactory', "dorkbox.util.Property",
'dorkbox.util.DelayTimer', "dorkbox.util.NamedThreadFactory",
'dorkbox.util.IO', "dorkbox.util.DelayTimer",
'dorkbox.util.FileUtil', "dorkbox.util.IO",
'dorkbox.util.Base64Fast', "dorkbox.util.FileUtil",
'dorkbox.util.RandomUtil', "dorkbox.util.Base64Fast",
'dorkbox.util.Sys', "dorkbox.util.RandomUtil",
'dorkbox.util.HashUtil', "dorkbox.util.Sys",
'dorkbox.util.NativeLoader', "dorkbox.util.HashUtil",
"dorkbox.util.NativeLoader",
'dorkbox.util.FastThreadLocal', "dorkbox.util.FastThreadLocal",
'dorkbox.util.LocationResolver', "dorkbox.util.LocationResolver",
'dorkbox.util.MathUtil', "dorkbox.util.MathUtil",
'dorkbox.util.MersenneTwisterFast', "dorkbox.util.MersenneTwisterFast",
'dorkbox.util.NativeLoader', "dorkbox.util.NativeLoader",
'dorkbox.util.NativeLoader', "dorkbox.util.NativeLoader",
'dorkbox.util.generics.TypeResolver', "dorkbox.util.generics.TypeResolver",
'dorkbox.util.generics.DefaultMethodHelper', // this class must be compiled java 8+ // "dorkbox.util.generics.DefaultMethodHelper", // this class must be compiled java 8+
'dorkbox.util.generics.ClassHelper', "dorkbox.util.generics.ClassHelper",
'dorkbox.util.bytes.BigEndian', "dorkbox.util.bytes.BigEndian",
'dorkbox.util.bytes.UByte', "dorkbox.util.bytes.UByte",
'dorkbox.util.bytes.UInteger', "dorkbox.util.bytes.UInteger",
'dorkbox.util.bytes.ULong', "dorkbox.util.bytes.ULong",
'dorkbox.util.bytes.Unsigned', "dorkbox.util.bytes.Unsigned",
'dorkbox.util.bytes.UNumber', "dorkbox.util.bytes.UNumber",
'dorkbox.util.bytes.UShort', "dorkbox.util.bytes.UShort",
'dorkbox.util.bytes.ByteArrayWrapper', "dorkbox.util.bytes.ByteArrayWrapper",
'dorkbox.util.bytes.OptimizeUtilsByteArray', "dorkbox.util.bytes.OptimizeUtilsByteArray",
'dorkbox.util.bytes.OptimizeUtilsByteBuf', "dorkbox.util.bytes.OptimizeUtilsByteBuf",
'dorkbox.util.exceptions.SecurityException', "dorkbox.util.exceptions.SecurityException",
'dorkbox.util.exceptions.InitializationException', "dorkbox.util.exceptions.InitializationException",
'dorkbox.util.collections.ObjectIntMap', "dorkbox.util.collections.ObjectIntMap",
'dorkbox.util.collections.IntMap', "dorkbox.util.collections.IntMap",
'dorkbox.util.collections.IntArray', "dorkbox.util.collections.IntArray",
'dorkbox.util.collections.ConcurrentIterator', "dorkbox.util.collections.ConcurrentIterator",
'dorkbox.util.collections.ConcurrentEntry', "dorkbox.util.collections.ConcurrentEntry",
'dorkbox.util.collections.LockFreeHashMap', "dorkbox.util.collections.LockFreeHashMap",
'dorkbox.util.collections.LockFreeIntMap', "dorkbox.util.collections.LockFreeIntMap",
'dorkbox.util.collections.LockFreeIntBiMap', "dorkbox.util.collections.LockFreeIntBiMap",
'dorkbox.util.collections.LockFreeObjectIntBiMap', "dorkbox.util.collections.LockFreeObjectIntBiMap",
'dorkbox.util.crypto.CryptoECC', "dorkbox.util.crypto.CryptoECC",
'dorkbox.util.crypto.CryptoAES') "dorkbox.util.crypto.CryptoAES"))
// entire packages/directories // entire packages/directories
include('dorkbox/util/serialization/**/*.java') include("dorkbox/util/serialization/**/*.java")
include('dorkbox/util/entropy/**/*.java') include("dorkbox/util/entropy/**/*.java")
include('dorkbox/util/storage/**/*.java') include("dorkbox/util/storage/**/*.java")
classpath = sourceSets.main.compileClasspath classpath = sourceSets["main"].compileClasspath
destinationDir = file("$rootDir/build/classes_utilities") destinationDir = file("$rootDir/build/classes_utilities")
} }
/////////////////////////////// /////////////////////////////////
////// Compile files to different target version //////// Compile some of the files to java 8
/////////////////////////////// /////////////////////////////////
//task compileFilesToJava8(type: JavaCompile) { task<JavaCompile>("compileUtilsJava8") {
// // we don't want the default include of **/*.java // we don't want the default include of **/*.java
// getIncludes().clear() includes.clear()
//
// source = Collections.singletonList('../Utilities/src') source = fileTree("../Utilities/src")
//
// include 'dorkbox/util/generics/DefaultMethodHelper.java' // this class must be compiled java 8+
// include(javaFile("dorkbox.util.generics.DefaultMethodHelper"))
// sourceCompatibility = 1.8
// targetCompatibility = 1.8 sourceCompatibility = JavaVersion.VERSION_1_8.toString()
// targetCompatibility = JavaVersion.VERSION_1_8.toString()
// classpath = sourceSets.main.compileClasspath
// destinationDir = sourceSets.main.output.classesDir classpath = sourceSets["main"].compileClasspath
//} destinationDir = file("$rootDir/build/classes_utilities")
println("Compiling $includes to Java $sourceCompatibility")
}
tasks.compileJava.get().apply {
println("Compiling classes to Java $sourceCompatibility")
}
/////////////////////////////// ///////////////////////////////
////// Jar Tasks ////// Jar Tasks
/////////////////////////////// ///////////////////////////////
jar { tasks.jar.get().apply {
dependsOn compileUtils dependsOn("compileUtils", "compileUtilsJava8")
// include applicable class files from subset of Utilities project // include applicable class files from subset of Utilities project
from compileUtils.destinationDir from((tasks["compileUtils"] as JavaCompile).destinationDir)
manifest {
// https://docs.oracle.com/javase/tutorial/deployment/jar/packageman.html
attributes["Name"] = Extras.name
attributes["Specification-Title"] = Extras.name
attributes["Specification-Version"] = Extras.version
attributes["Specification-Vendor"] = Extras.vendor
attributes["Implementation-Title"] = "${Extras.group}.${Extras.id}"
attributes["Implementation-Version"] = Extras.buildDate
attributes["Implementation-Vendor"] = Extras.vendor
}
} }
///////////////////////////// ///////////////////////////////
//// Maven Publishing + Release ////// Maven Publishing + Release
///////////////////////////// ///////////////////////////////
task sourceJar(type: Jar) { val sourceJar = task<Jar>("sourceJar") {
description = "Creates a JAR that contains the source code." description = "Creates a JAR that contains the source code."
from sourceSets.main.java from(sourceSets["main"].java)
classifier = "sources" archiveClassifier.set("sources")
} }
task javaDocJar(type: Jar) { val javaDocJar = task<Jar>("javaDocJar") {
description = "Creates a JAR that contains the javadocs." description = "Creates a JAR that contains the javadocs."
classifier = "javadoc" archiveClassifier.set("javadoc")
} }
// for testing, we don't publish to maven central, but only to local maven
///////////////////////////////
// functions to make changing the maven POM easier
@Suppress("UNCHECKED_CAST")
fun org.gradle.api.publish.maven.MavenPom.removeDependenciesByArtifactId(vararg names: String) {
withXml {
(asNode().get("dependencies") as List<groovy.util.Node>).forEach {deps ->
(deps.children() as List<groovy.util.Node>).filter { it ->
val text = (it.get("artifactId") as List<groovy.util.Node>).firstOrNull()?.text()
if (text == null) {
false
} else {
names.contains(text)
}
}.forEach { node->
node.parent().remove(node)
}
}
}
}
///////////////////////////////
////// PUBLISH TO SONATYPE / MAVEN CENTRAL
//////
////// TESTING : local maven repo <PUBLISHING - publishToMavenLocal>
//////
////// RELEASE : sonatype / maven central, <PUBLISHING - publish> then <RELEASE - CloseAndReleaseRepository>
///////////////////////////////
publishing { publishing {
publications { publications {
maven(MavenPublication) { create<MavenPublication>("maven") {
from components.java groupId = Extras.group
artifactId = Extras.id
version = Extras.version
from(components["java"])
artifact(javaDocJar)
artifact(sourceJar) artifact(sourceJar)
artifact(javaDocJar)
groupId project.group
artifactId project.ext.name
version project.version
pom { pom {
withXml { name.set(Extras.name)
// eliminate logback and utilities (no need in maven POMs) description.set(Extras.description)
def root = asNode() url.set(Extras.url)
root.dependencies.'*'.findAll() { removeDependenciesByArtifactId("Utilities")
it.artifactId.text() == "Utilities"
}.each() {
it.parent().remove(it)
}
}
name = project.ext.name
url = project.ext.url
description = project.description
issueManagement { issueManagement {
url = "${project.ext.url}/issues".toString() url.set("${Extras.url}/issues")
system = 'Gitea Issues' system.set("Gitea Issues")
} }
organization { organization {
name = 'dorkbox, llc' name.set(Extras.vendor)
url = 'https://dorkbox.com' url.set("https://dorkbox.com")
} }
developers { developers {
developer { developer {
name = 'dorkbox, llc' id.set("dorkbox")
email = 'email@dorkbox.com' name.set(Extras.vendor)
email.set("email@dorkbox.com")
}
}
scm {
url.set(Extras.url)
connection.set("scm:${Extras.url}.git")
} }
} }
scm {
url = project.ext.url
connection = "scm:${project.ext.url}.git".toString()
}
}
} }
} }
repositories { repositories {
maven { maven {
url "https://oss.sonatype.org/service/local/staging/deploy/maven2" setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2")
credentials { credentials {
username sonatypeUsername username = Extras.sonatypeUsername
password sonatypePassword password = Extras.sonatypePassword
} }
} }
} }
tasks.withType<PublishToMavenRepository> {
onlyIf {
publication == publishing.publications["maven"] && repository == publishing.repositories["maven"]
}
}
tasks.withType<PublishToMavenLocal> {
onlyIf {
publication == publishing.publications["maven"]
}
}
// output the release URL in the console
tasks["releaseRepository"].doLast {
val url = "https://oss.sonatype.org/content/repositories/releases/"
val projectName = Extras.group.replace('.', '/')
val name = Extras.name
val version = Extras.version
println("Maven URL: $url$projectName/$name/$version/")
}
} }
nexusStaging { nexusStaging {
username sonatypeUsername username = Extras.sonatypeUsername
password sonatypePassword password = Extras.sonatypePassword
} }
signing { signing {
sign publishing.publications.maven sign(publishing.publications["maven"])
} }
// output the release URL in the console ///////////////////////////////
releaseRepository.doLast { ///// Prevent anything other than a release from showing version updates
def URL = 'https://oss.sonatype.org/content/repositories/releases/' //// https://github.com/ben-manes/gradle-versions-plugin/blob/master/README.md
def projectName = project.group.toString().replaceAll('\\.', '/') ///////////////////////////////
def name = project.ext.name tasks.named<DependencyUpdatesTask>("dependencyUpdates") {
def version = project.version resolutionStrategy {
componentSelection {
println("Maven URL: ${URL}${projectName}/${name}/${version}/") all {
} val rejected = listOf("alpha", "beta", "rc", "cr", "m", "preview")
.map { qualifier -> Regex("(?i).*[.-]$qualifier[.\\d-]*") }
// we don't use maven with the plugin (it's uploaded separately to gradle plugins) .any { it.matches(candidate.version) }
tasks.withType(PublishToMavenRepository) { if (rejected) {
onlyIf { reject("Release candidate")
repository == publishing.repositories.maven && publication == publishing.publications.maven
} }
} }
tasks.withType(PublishToMavenLocal) {
onlyIf {
publication == publishing.publications.maven
} }
} }
///////////////////////////// // optional parameters
//// Gradle Wrapper Configuration. checkForGradleUpdate = true
/// Run this task, then refresh the gradle project }
/////////////////////////////
task updateWrapper(type: Wrapper) { ///////////////////////////////
gradleVersion = '5.1' ////// Gradle Wrapper Configuration.
///// Run this task, then refresh the gradle project
///////////////////////////////
val wrapperUpdate by tasks.creating(Wrapper::class) {
gradleVersion = "5.1.1"
distributionUrl = distributionUrl.replace("bin", "all") distributionUrl = distributionUrl.replace("bin", "all")
setDistributionType(Wrapper.DistributionType.ALL)
} }

2
gradlew vendored
View File

@ -28,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="" DEFAULT_JVM_OPTS='"-Xmx64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"

2
gradlew.bat vendored
View File

@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS= set DEFAULT_JVM_OPTS="-Xmx64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome

View File

@ -16,9 +16,9 @@
include("Utilities") include("Utilities")
for (project in rootProject.children) { for (project in rootProject.children) {
project.projectDir = file("../$project.name") project.projectDir = file("../${project.name}")
project.buildFileName = "utilities.gradle" project.buildFileName = "utilities.gradle"
assert (project.projectDir.directory) assert (project.projectDir.isDirectory)
assert (project.buildFile.file) assert (project.buildFile.isFile)
} }