2018-08-18 23:15:46 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2018 dorkbox, llc
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import java.nio.file.Paths
|
|
|
|
import java.time.Instant
|
|
|
|
|
|
|
|
buildscript {
|
|
|
|
// load properties from custom location
|
2018-08-27 23:11:05 +02:00
|
|
|
def propsFile = Paths.get("${projectDir}/../../gradle.properties").normalize().toFile()
|
|
|
|
if (propsFile.canRead()) {
|
|
|
|
println("Loading custom property data from: ${propsFile}")
|
2018-08-18 23:15:46 +02:00
|
|
|
|
2018-08-27 23:11:05 +02:00
|
|
|
def props = new Properties()
|
|
|
|
propsFile.withInputStream {props.load(it)}
|
|
|
|
props.each {key, val -> project.ext.set(key, val)}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ext.sonatypeUsername = ""
|
|
|
|
ext.sonatypePassword = ""
|
|
|
|
}
|
2018-08-18 23:15:46 +02:00
|
|
|
|
|
|
|
// 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.2.2"
|
|
|
|
classpath "gradle.plugin.com.dorkbox:Licensing:1.2.2:sources"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
id 'java'
|
|
|
|
id 'maven-publish'
|
|
|
|
id 'signing'
|
|
|
|
|
|
|
|
// close and release on sonatype
|
|
|
|
id 'io.codearte.nexus-staging' version '0.11.0'
|
|
|
|
|
|
|
|
id "com.dorkbox.CrossCompile" version "1.0.1"
|
|
|
|
id "com.dorkbox.VersionUpdate" version "1.2"
|
|
|
|
|
|
|
|
// setup checking for the latest version of a plugin or dependency (and updating the gradle build)
|
|
|
|
id "se.patrikerdes.use-latest-versions" version "0.2.3"
|
|
|
|
id 'com.github.ben-manes.versions' version '0.16.0'
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
apply plugin: 'java-library'
|
|
|
|
|
|
|
|
|
|
|
|
project.description = 'Encrypted, high-performance, and event-driven/reactive network stack for Java 6+'
|
|
|
|
project.group = 'com.dorkbox'
|
|
|
|
project.version = '2.11'
|
|
|
|
|
|
|
|
project.ext.name = 'Network'
|
|
|
|
project.ext.url = 'https://git.dorkbox.com/dorkbox/Network'
|
|
|
|
|
|
|
|
|
|
|
|
sourceCompatibility = 1.8
|
|
|
|
targetCompatibility = 1.8
|
|
|
|
|
|
|
|
|
|
|
|
licensing {
|
|
|
|
license(License.APACHE_2) {
|
|
|
|
author 'dorkbox, llc'
|
|
|
|
url project.ext.url
|
|
|
|
note project.description
|
|
|
|
}
|
|
|
|
|
|
|
|
license('Dorkbox Utils', License.APACHE_2) {
|
|
|
|
author 'dorkbox, llc'
|
|
|
|
url 'https://git.dorkbox.com/dorkbox/Utilities'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('Bennidi Iterator', License.MIT) {
|
|
|
|
copyright 2012
|
|
|
|
author 'Benjamin Diedrichsen'
|
|
|
|
url 'https://github.com/bennidi/mbassador'
|
|
|
|
note 'Fast iterators from the MBassador project'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('BouncyCastle', License.MIT) {
|
|
|
|
copyright 2009
|
|
|
|
author 'The Legion Of The Bouncy Castle'
|
|
|
|
url 'http://www.bouncycastle.org'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('ObjectPool', License.APACHE_2) {
|
|
|
|
author 'dorkbox, llc'
|
|
|
|
url 'https://git.dorkbox.com/dorkbox/ObjectPool'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('FastThreadLocal', License.BSD_3) {
|
|
|
|
copyright 2014
|
|
|
|
author 'Lightweight Java Game Library Project'
|
|
|
|
author 'Riven'
|
|
|
|
url 'https://github.com/LWJGL/lwjgl3/blob/5819c9123222f6ce51f208e022cb907091dd8023/modules/core/src/main/java/org/lwjgl/system/FastThreadLocal.java'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('Javassist', License.BSD_3) {
|
|
|
|
copyright 1999
|
|
|
|
author 'Shigeru Chiba'
|
|
|
|
author 'Bill Burke'
|
|
|
|
author 'Jason T. Greene'
|
|
|
|
url 'http://www.csg.is.titech.ac.jp/~chiba/java'
|
|
|
|
note 'Licensed under the MPL/LGPL/Apache triple license'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('Kryo', License.BSD_3) {
|
|
|
|
copyright 2008
|
|
|
|
author 'Nathan Sweet'
|
|
|
|
url 'https://github.com/EsotericSoftware/kryo'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('kryo-serializers', License.APACHE_2) {
|
|
|
|
copyright 2010
|
|
|
|
author 'Martin Grotzke'
|
|
|
|
author 'Rafael Winterhalter'
|
|
|
|
url 'https://github.com/magro/kryo-serializers'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('KryoNet RMI', License.BSD_3) {
|
|
|
|
copyright 2008
|
|
|
|
author 'Nathan Sweet'
|
|
|
|
url 'https://github.com/EsotericSoftware/kryonet'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('LAN HostDiscovery from Apache Commons JCS', License.APACHE_2) {
|
|
|
|
copyright 2014
|
|
|
|
author 'The Apache Software Foundation'
|
|
|
|
url 'https://issues.apache.org/jira/browse/JCS-40'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('LZ4 and XXhash', License.APACHE_2) {
|
|
|
|
copyright 2011
|
|
|
|
copyright 2012
|
|
|
|
author 'Yann Collet'
|
|
|
|
author 'Adrien Grand'
|
|
|
|
url 'https://github.com/jpountz/lz4-java'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('MathUtils, IntArray, IntMap', License.APACHE_2) {
|
|
|
|
copyright 2013
|
|
|
|
author 'Mario Zechner <badlogicgames@gmail.com>'
|
|
|
|
author 'Nathan Sweet <nathan.sweet@gmail.com>'
|
|
|
|
url 'http://github.com/libgdx/libgdx/'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('MinLog-SLF4J', License.APACHE_2) {
|
|
|
|
copyright 2008
|
|
|
|
author 'dorkbox, llc'
|
|
|
|
author 'Nathan Sweet'
|
|
|
|
author 'Dan Brown'
|
|
|
|
url 'https://git.dorkbox.com/dorkbox/MinLog-SLF4J'
|
|
|
|
url 'https://github.com/EsotericSoftware/minlog'
|
|
|
|
note 'Drop-in replacement for MinLog to log through SLF4j.'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('ReflectASM', License.BSD_3) {
|
|
|
|
copyright 2008
|
|
|
|
author 'Nathan Sweet'
|
|
|
|
url 'https://github.com/EsotericSoftware/reflectasm'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('SLF4J', License.MIT) {
|
|
|
|
copyright 2008
|
|
|
|
author 'QOS.ch'
|
|
|
|
url 'http://www.slf4j.org'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('TypeTools', License.APACHE_2) {
|
|
|
|
copyright 2017
|
|
|
|
author 'Jonathan Halterman'
|
|
|
|
url 'https://github.com/jhalterman/typetools/'
|
|
|
|
note 'Tools for resolving generic types'
|
|
|
|
}
|
|
|
|
|
|
|
|
license('XBill DNS', License.BSD_3) {
|
|
|
|
copyright 2005
|
|
|
|
author 'Brian Wellington'
|
|
|
|
url 'http://www.xbill.org/dnsjava'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
java {
|
|
|
|
setSrcDirs Collections.singletonList('src')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenLocal() // this must be first!
|
|
|
|
jcenter()
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ext {
|
|
|
|
bcVersion = '1.60'
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
implementation(project('Utilities')) {
|
|
|
|
// don't include any of the project dependencies for anything
|
|
|
|
transitive = false
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
api 'net.java.dev.jna:jna:4.5.2'
|
|
|
|
api 'net.java.dev.jna:jna-platform:4.5.2'
|
|
|
|
|
|
|
|
api 'io.netty:netty-all:4.1.22.Final'
|
|
|
|
api 'com.esotericsoftware:kryo:4.0.2'
|
|
|
|
api 'net.jpountz.lz4:lz4:1.3.0'
|
|
|
|
|
|
|
|
api "org.bouncycastle:bcprov-jdk15on:$bcVersion"
|
|
|
|
api "org.bouncycastle:bcpg-jdk15on:$bcVersion"
|
|
|
|
api "org.bouncycastle:bcmail-jdk15on:$bcVersion"
|
|
|
|
api "org.bouncycastle:bctls-jdk15on:$bcVersion"
|
|
|
|
|
|
|
|
api "com.dorkbox:ObjectPool:2.11"
|
|
|
|
|
|
|
|
api 'org.slf4j:slf4j-api:1.7.25'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
project('Utilities') {
|
|
|
|
tasks.withType(Test) {
|
|
|
|
// want to remove utilities project from unit tests. It's unnecessary to run unit tests for the entire Utilities project
|
|
|
|
exclude('**/*')
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType(JavaCompile) {
|
|
|
|
options.encoding = 'UTF-8'
|
|
|
|
options.incremental = true
|
|
|
|
|
|
|
|
// setup compile options. we specifically want to suppress usage of "Unsafe"
|
|
|
|
options.compilerArgs = ['-XDignore.symbol.file', '-Xlint:deprecation']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////
|
|
|
|
////// Task defaults
|
|
|
|
///////////////////////////////
|
|
|
|
tasks.withType(JavaCompile) {
|
|
|
|
options.encoding = 'UTF-8'
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType(Jar) {
|
|
|
|
duplicatesStrategy DuplicatesStrategy.FAIL
|
|
|
|
|
|
|
|
manifest {
|
|
|
|
attributes['Implementation-Version'] = version
|
|
|
|
attributes['Build-Date'] = Instant.now().toString()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////
|
|
|
|
////// UTILITIES COMPILE (for inclusion into jars)
|
|
|
|
///////////////////////////////
|
|
|
|
static String[] javaFile(String... fileNames) {
|
|
|
|
def fileList = [] as ArrayList
|
|
|
|
|
|
|
|
for (name in fileNames) {
|
|
|
|
def fixed = name.replace('.', '/') + '.java'
|
|
|
|
fileList.add(fixed)
|
|
|
|
}
|
|
|
|
|
|
|
|
return fileList
|
|
|
|
}
|
|
|
|
|
|
|
|
task compileUtils(type: JavaCompile) {
|
|
|
|
// we don't want the default include of **/*.java
|
|
|
|
getIncludes().clear()
|
|
|
|
|
|
|
|
source = Collections.singletonList('../Utilities/src')
|
|
|
|
include javaFile('dorkbox.util.OS',
|
|
|
|
'dorkbox.util.OSType',
|
|
|
|
'dorkbox.util.Property',
|
|
|
|
'dorkbox.util.NamedThreadFactory',
|
|
|
|
'dorkbox.util.DelayTimer',
|
|
|
|
'dorkbox.util.IO',
|
|
|
|
'dorkbox.util.FileUtil',
|
|
|
|
'dorkbox.util.Base64Fast',
|
|
|
|
'dorkbox.util.RandomUtil',
|
|
|
|
'dorkbox.util.Sys',
|
|
|
|
'dorkbox.util.HashUtil',
|
|
|
|
'dorkbox.util.NativeLoader',
|
|
|
|
|
|
|
|
'dorkbox.util.FastThreadLocal',
|
|
|
|
'dorkbox.util.LocationResolver',
|
|
|
|
'dorkbox.util.MathUtil',
|
|
|
|
'dorkbox.util.MersenneTwisterFast',
|
|
|
|
'dorkbox.util.NativeLoader',
|
|
|
|
'dorkbox.util.NativeLoader',
|
|
|
|
|
|
|
|
'dorkbox.util.generics.TypeResolver',
|
|
|
|
// 'dorkbox.util.generics.DefaultMethodHelper', // this class must be compiled java 8+
|
|
|
|
'dorkbox.util.generics.ClassHelper',
|
|
|
|
|
|
|
|
'dorkbox.util.bytes.BigEndian',
|
|
|
|
'dorkbox.util.bytes.UByte',
|
|
|
|
'dorkbox.util.bytes.UInteger',
|
|
|
|
'dorkbox.util.bytes.ULong',
|
|
|
|
'dorkbox.util.bytes.Unsigned',
|
|
|
|
'dorkbox.util.bytes.UNumber',
|
|
|
|
'dorkbox.util.bytes.UShort',
|
|
|
|
'dorkbox.util.bytes.ByteArrayWrapper',
|
|
|
|
'dorkbox.util.bytes.OptimizeUtilsByteArray',
|
|
|
|
'dorkbox.util.bytes.OptimizeUtilsByteBuf',
|
|
|
|
|
|
|
|
'dorkbox.util.exceptions.SecurityException',
|
|
|
|
'dorkbox.util.exceptions.InitializationException',
|
|
|
|
|
|
|
|
|
|
|
|
'dorkbox.util.collections.ObjectIntMap',
|
|
|
|
'dorkbox.util.collections.IntMap',
|
|
|
|
'dorkbox.util.collections.IntArray',
|
|
|
|
'dorkbox.util.collections.ConcurrentIterator',
|
|
|
|
'dorkbox.util.collections.ConcurrentEntry',
|
|
|
|
'dorkbox.util.collections.LockFreeHashMap',
|
|
|
|
'dorkbox.util.collections.LockFreeIntMap',
|
|
|
|
'dorkbox.util.collections.LockFreeIntBiMap',
|
|
|
|
'dorkbox.util.collections.LockFreeObjectIntBiMap',
|
|
|
|
|
|
|
|
'dorkbox.util.crypto.CryptoECC',
|
|
|
|
'dorkbox.util.crypto.CryptoAES')
|
|
|
|
|
|
|
|
// entire packages/directories
|
|
|
|
include('dorkbox.util.serialization/**/*.java')
|
|
|
|
include('dorkbox.util.entropy/**/*.java')
|
|
|
|
include('dorkbox.util.storage/**/*.java')
|
|
|
|
|
|
|
|
|
|
|
|
classpath = sourceSets.main.compileClasspath
|
|
|
|
destinationDir = file("$rootDir/build/classes_utilities")
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////
|
|
|
|
////// Compile files to different target version
|
|
|
|
///////////////////////////////
|
|
|
|
//task compileFilesToJava8(type: JavaCompile) {
|
|
|
|
// source = sourceSets.main.java.srcDirs
|
|
|
|
//
|
|
|
|
// include 'dorkbox/util/generics/DefaultMethodHelper.java'
|
|
|
|
//
|
|
|
|
// classpath = sourceSets.main.compileClasspath
|
|
|
|
// destinationDir = sourceSets.main.output.classesDir
|
|
|
|
//}
|
|
|
|
|
|
|
|
///////////////////////////////
|
|
|
|
////// Jar Tasks
|
|
|
|
///////////////////////////////
|
|
|
|
jar {
|
|
|
|
dependsOn compileUtils
|
|
|
|
|
|
|
|
// include applicable class files from subset of Utilities project
|
|
|
|
from compileUtils.destinationDir
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////
|
|
|
|
//// Maven Publishing + Release
|
|
|
|
/////////////////////////////
|
|
|
|
task sourceJar(type: Jar) {
|
|
|
|
description = "Creates a JAR that contains the source code."
|
|
|
|
|
|
|
|
from sourceSets.main.java
|
|
|
|
|
|
|
|
classifier = "sources"
|
|
|
|
}
|
|
|
|
|
|
|
|
task javaDocJar(type: Jar) {
|
|
|
|
description = "Creates a JAR that contains the javadocs."
|
|
|
|
|
|
|
|
classifier = "javadoc"
|
|
|
|
}
|
|
|
|
|
|
|
|
// for testing, we don't publish to maven central, but only to local maven
|
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
maven(MavenPublication) {
|
|
|
|
from components.java
|
|
|
|
|
|
|
|
artifact(javaDocJar)
|
|
|
|
artifact(sourceJar)
|
|
|
|
|
|
|
|
groupId project.group
|
|
|
|
artifactId project.ext.name
|
|
|
|
version project.version
|
|
|
|
|
|
|
|
pom {
|
|
|
|
withXml {
|
|
|
|
// eliminate logback and utilities (no need in maven POMs)
|
|
|
|
def root = asNode()
|
|
|
|
|
|
|
|
root.dependencies.'*'.findAll() {
|
|
|
|
it.artifactId.text() == "Utilities"
|
|
|
|
}.each() {
|
|
|
|
it.parent().remove(it)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
name = project.ext.name
|
|
|
|
url = project.ext.url
|
|
|
|
description = project.description
|
|
|
|
|
|
|
|
issueManagement {
|
|
|
|
url = "${project.ext.url}/issues".toString()
|
|
|
|
system = 'Gitea Issues'
|
|
|
|
}
|
|
|
|
|
|
|
|
organization {
|
|
|
|
name = 'dorkbox, llc'
|
|
|
|
url = 'https://dorkbox.com'
|
|
|
|
}
|
|
|
|
|
|
|
|
developers {
|
|
|
|
developer {
|
|
|
|
name = 'dorkbox, llc'
|
|
|
|
email = 'email@dorkbox.com'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scm {
|
|
|
|
url = project.ext.url
|
|
|
|
connection = "scm:${project.ext.url}.git".toString()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
|
|
|
credentials {
|
|
|
|
username sonatypeUsername
|
|
|
|
password sonatypePassword
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nexusStaging {
|
|
|
|
username sonatypeUsername
|
|
|
|
password sonatypePassword
|
|
|
|
}
|
|
|
|
|
|
|
|
signing {
|
|
|
|
sign publishing.publications.maven
|
|
|
|
}
|
|
|
|
|
|
|
|
// output the release URL in the console
|
|
|
|
releaseRepository.doLast {
|
|
|
|
def URL = 'https://oss.sonatype.org/content/repositories/releases/'
|
|
|
|
def projectName = project.group.toString().replaceAll('\\.', '/')
|
|
|
|
def name = project.ext.name
|
|
|
|
def version = project.version
|
|
|
|
|
|
|
|
println("Maven URL: ${URL}${projectName}/${name}/${version}/")
|
|
|
|
}
|
|
|
|
|
|
|
|
// we don't use maven with the plugin (it's uploaded separately to gradle plugins)
|
|
|
|
tasks.withType(PublishToMavenRepository) {
|
|
|
|
onlyIf {
|
|
|
|
repository == publishing.repositories.maven && publication == publishing.publications.maven
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tasks.withType(PublishToMavenLocal) {
|
|
|
|
onlyIf {
|
|
|
|
publication == publishing.publications.maven
|
|
|
|
}
|
|
|
|
}
|
2018-09-25 20:02:39 +02:00
|
|
|
|
|
|
|
/////////////////////////////
|
|
|
|
//// Gradle Wrapper Configuration.
|
|
|
|
/// Run this task, then refresh the gradle project
|
|
|
|
/////////////////////////////
|
|
|
|
task updateWrapper(type: Wrapper) {
|
|
|
|
gradleVersion = '4.10.2'
|
|
|
|
distributionUrl = distributionUrl.replace("bin", "all")
|
|
|
|
setDistributionType(Wrapper.DistributionType.ALL)
|
2018-09-25 20:10:57 +02:00
|
|
|
}
|