2018-08-03 05:10:29 +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.
|
|
|
|
*/
|
|
|
|
|
2018-08-05 15:25:53 +02:00
|
|
|
import java.nio.file.Paths
|
|
|
|
import java.time.Instant
|
|
|
|
|
2018-08-03 05:10:29 +02:00
|
|
|
buildscript {
|
|
|
|
// load properties from custom location
|
2018-08-27 23:12:24 +02:00
|
|
|
def propsFile = Paths.get("${projectDir}/../../gradle.properties").normalize().toFile()
|
|
|
|
if (propsFile.canRead()) {
|
|
|
|
println("Loading custom property data from: ${propsFile}")
|
2018-08-03 05:10:29 +02:00
|
|
|
|
2018-08-27 23:12:24 +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-03 05:10:29 +02:00
|
|
|
|
|
|
|
repositories {
|
|
|
|
maven {url "https://plugins.gradle.org/m2/"}
|
|
|
|
}
|
|
|
|
dependencies {
|
2018-08-13 15:23:36 +02:00
|
|
|
// for license sources
|
2018-08-05 15:25:53 +02:00
|
|
|
classpath "gradle.plugin.com.dorkbox:Licensing:1.2.2"
|
|
|
|
classpath "gradle.plugin.com.dorkbox:Licensing:1.2.2:sources"
|
2018-08-03 05:10:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
id 'java'
|
|
|
|
id 'maven-publish'
|
|
|
|
id 'signing'
|
|
|
|
|
2018-08-05 15:25:53 +02:00
|
|
|
id "org.jetbrains.kotlin.jvm" version "1.2.60"
|
2018-08-03 05:10:29 +02:00
|
|
|
|
|
|
|
// close and release on sonatype
|
|
|
|
id 'io.codearte.nexus-staging' version '0.11.0'
|
2018-08-05 15:25:53 +02:00
|
|
|
|
2018-08-13 15:23:36 +02:00
|
|
|
id "com.dorkbox.CrossCompile" version "1.0.1"
|
2018-08-18 14:32:21 +02:00
|
|
|
id "com.dorkbox.VersionUpdate" version "1.2"
|
2018-08-03 05:10:29 +02:00
|
|
|
}
|
|
|
|
|
2018-08-13 15:23:36 +02:00
|
|
|
// this is the only way to also get the source code for IDE auto-complete
|
2018-08-03 05:10:29 +02:00
|
|
|
apply plugin: "com.dorkbox.Licensing"
|
|
|
|
|
|
|
|
|
2018-08-05 15:25:53 +02:00
|
|
|
project.description = 'Java Semantic Versioning with patch info exclusion'
|
2018-08-03 05:10:29 +02:00
|
|
|
project.group = 'com.dorkbox'
|
2018-08-05 16:52:49 +02:00
|
|
|
project.version = '1.0'
|
2018-08-03 05:10:29 +02:00
|
|
|
|
2018-08-05 16:39:32 +02:00
|
|
|
project.ext.name = 'Version'
|
|
|
|
project.ext.url = 'https://git.dorkbox.com/dorkbox/Version'
|
2018-08-03 05:10:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
sourceCompatibility = 1.6
|
|
|
|
targetCompatibility = 1.6
|
|
|
|
|
|
|
|
|
|
|
|
licensing {
|
|
|
|
license(License.MIT) {
|
|
|
|
author 'dorkbox, llc'
|
|
|
|
author 'G. Richard Bellamy'
|
|
|
|
author 'Kenduck'
|
|
|
|
author 'Larry Bordowitz <lbordowitz@yahoo-inc.com>'
|
|
|
|
author 'Martin Rüegg <martin.rueegg@bristolpound.org> <martin.rueegg@metaworx.ch>'
|
|
|
|
author 'Zafar Khaja <zafarkhaja@gmail.com>'
|
|
|
|
url project.ext.url
|
|
|
|
note project.description
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType(JavaCompile) {
|
|
|
|
options.encoding = 'UTF-8'
|
|
|
|
}
|
|
|
|
|
2018-08-05 15:25:53 +02:00
|
|
|
tasks.withType(Jar) {
|
|
|
|
duplicatesStrategy DuplicatesStrategy.FAIL
|
|
|
|
|
|
|
|
manifest {
|
|
|
|
attributes['Implementation-Version'] = project.version
|
|
|
|
attributes['Build-Date'] = Instant.now().toString()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-03 05:10:29 +02:00
|
|
|
repositories {
|
|
|
|
jcenter()
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
testCompile group: 'junit', name: 'junit', version:'4.12'
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
java {
|
|
|
|
setSrcDirs Collections.singletonList('src')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test {
|
|
|
|
java {
|
|
|
|
setSrcDirs Collections.singletonList('test')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-05 15:25:53 +02:00
|
|
|
/////////////////////////////
|
|
|
|
//// Maven Publishing + Release
|
|
|
|
/////////////////////////////
|
|
|
|
task sourceJar(type: Jar) {
|
|
|
|
description = "Creates a JAR that contains the source code."
|
2018-08-03 05:10:29 +02:00
|
|
|
|
2018-08-05 15:25:53 +02:00
|
|
|
from sourceSets.main.allSource
|
2018-08-03 05:10:29 +02:00
|
|
|
|
2018-08-05 15:25:53 +02:00
|
|
|
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 {
|
|
|
|
SemanticVersioning(MavenPublication) {
|
|
|
|
from components.java
|
|
|
|
|
|
|
|
artifact(javaDocJar)
|
|
|
|
artifact(sourceJar)
|
|
|
|
|
|
|
|
groupId project.group
|
2018-08-18 11:31:20 +02:00
|
|
|
artifactId project.ext.name
|
2018-08-05 15:25:53 +02:00
|
|
|
version project.version
|
|
|
|
|
|
|
|
pom {
|
|
|
|
withXml {
|
|
|
|
// eliminate logback compile dependencies (no need in maven central POMs)
|
|
|
|
def root = asNode()
|
|
|
|
|
|
|
|
root.dependencies.'*'.findAll() {
|
|
|
|
it.groupId.text() == "ch.qos.logback" && it.artifactId.text() == "logback-classic"
|
|
|
|
}.each() {
|
|
|
|
it.parent().remove(it)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-18 11:31:20 +02:00
|
|
|
name = project.ext.name
|
2018-08-05 15:25:53 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
signing {
|
|
|
|
required {hasProperty('sonatypeUsername')}
|
|
|
|
sign publishing.publications.SemanticVersioning
|
|
|
|
}
|
|
|
|
|
2018-08-05 17:05:24 +02:00
|
|
|
nexusStaging {
|
|
|
|
username sonatypeUsername
|
|
|
|
password sonatypePassword
|
|
|
|
}
|
|
|
|
|
2018-08-05 17:16:13 +02:00
|
|
|
// output the release URL in the console
|
|
|
|
releaseRepository.doLast {
|
|
|
|
def URL = 'https://oss.sonatype.org/content/repositories/releases/'
|
|
|
|
def projectName = project.group.toString().replaceAll('\\.', '/')
|
2018-08-18 11:31:20 +02:00
|
|
|
def name = project.ext.name
|
2018-08-05 17:16:13 +02:00
|
|
|
def version = project.version
|
|
|
|
|
|
|
|
println("Maven URL: ${URL}${projectName}/${name}/${version}/")
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-05 15:25:53 +02:00
|
|
|
// 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.SemanticVersioning
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tasks.withType(PublishToMavenLocal) {
|
|
|
|
onlyIf {
|
|
|
|
publication == publishing.publications.SemanticVersioning
|
|
|
|
}
|
|
|
|
}
|