2018-07-17 04:01:51 +02:00
|
|
|
import java.nio.file.Paths
|
|
|
|
|
2018-06-30 23:22:05 +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.
|
|
|
|
*/
|
|
|
|
buildscript {
|
2018-07-17 04:01:51 +02:00
|
|
|
// load properties from custom location
|
2018-07-17 21:12:12 +02:00
|
|
|
def propsFile = Paths.get("${projectDir}/../../gradle.properties").toAbsolutePath().normalize().toFile()
|
2018-07-17 04:01:51 +02:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
// for plugin publishing
|
2018-06-30 23:22:05 +02:00
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
url "https://plugins.gradle.org/m2/"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dependencies {
|
|
|
|
classpath "com.gradle.publish:plugin-publish-plugin:0.9.10"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-17 21:12:12 +02:00
|
|
|
|
2018-06-30 23:22:05 +02:00
|
|
|
plugins {
|
|
|
|
id 'java'
|
|
|
|
id 'java-gradle-plugin'
|
|
|
|
id 'maven-publish'
|
2018-07-17 03:12:24 +02:00
|
|
|
id 'signing'
|
2018-06-30 23:22:05 +02:00
|
|
|
|
2018-07-14 21:23:25 +02:00
|
|
|
id "org.jetbrains.kotlin.jvm" version "1.2.51"
|
2018-07-17 03:12:24 +02:00
|
|
|
|
2018-07-17 04:01:51 +02:00
|
|
|
// close and release on sonatype
|
2018-07-17 03:12:24 +02:00
|
|
|
id 'io.codearte.nexus-staging' version '0.11.0'
|
2018-06-30 23:22:05 +02:00
|
|
|
}
|
|
|
|
|
2018-07-17 04:01:51 +02:00
|
|
|
// for publishing the plugin to gradle
|
2018-06-30 23:22:05 +02:00
|
|
|
apply plugin: "com.gradle.plugin-publish"
|
|
|
|
|
|
|
|
|
|
|
|
project.description = 'License definitions and legal management plugin for the Gradle build system'
|
|
|
|
project.group = 'com.dorkbox'
|
2018-07-17 03:12:24 +02:00
|
|
|
project.version = '1.1.0'
|
2018-06-30 23:22:05 +02:00
|
|
|
|
|
|
|
project.ext.name = 'Gradle Licensing Plugin'
|
|
|
|
project.ext.id = 'Licensing'
|
|
|
|
project.ext.website = 'https://dorkbox.com/'
|
|
|
|
project.ext.url = 'https://git.dorkbox.com/dorkbox/Licensing'
|
2018-06-30 23:43:31 +02:00
|
|
|
project.ext.tags = ['licensing', 'legal', 'notice', 'license', 'dependencies']
|
2018-06-30 23:22:05 +02:00
|
|
|
|
2018-07-17 21:12:12 +02:00
|
|
|
|
2018-06-30 23:22:05 +02:00
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
java {
|
|
|
|
setSrcDirs Collections.singletonList('src')
|
|
|
|
}
|
|
|
|
|
|
|
|
resources {
|
|
|
|
setSrcDirs Collections.singletonList('resources')
|
|
|
|
|
|
|
|
srcDirs '.'
|
|
|
|
include 'LICENSE*'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
jcenter()
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
compileOnly 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.50'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tasks.withType(JavaCompile) {
|
|
|
|
options.encoding = 'UTF-8'
|
|
|
|
options.incremental = true
|
|
|
|
}
|
|
|
|
|
2018-07-17 04:01:51 +02:00
|
|
|
///////////////////////////////
|
|
|
|
////// Plugin Publishing + Release
|
|
|
|
///////////////////////////////
|
2018-06-30 23:22:05 +02:00
|
|
|
gradlePlugin {
|
|
|
|
plugins {
|
2018-07-17 03:12:24 +02:00
|
|
|
licensing {
|
2018-06-30 23:22:05 +02:00
|
|
|
id = "${project.group}.${project.ext.id}"
|
|
|
|
implementationClass = 'dorkbox.license.LicensePlugin'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-17 04:01:51 +02:00
|
|
|
pluginBundle {
|
|
|
|
website = project.ext.website
|
|
|
|
vcsUrl = project.ext.url
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
licensing {
|
|
|
|
id = "${project.group}.${project.ext.id}"
|
|
|
|
displayName = project.ext.name
|
|
|
|
description = project.description
|
|
|
|
tags = project.ext.tags
|
|
|
|
version = project.version
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-17 03:12:24 +02:00
|
|
|
///////////////////////////////
|
2018-07-17 04:01:51 +02:00
|
|
|
////// Maven Publishing + Release
|
2018-07-17 03:12:24 +02:00
|
|
|
///////////////////////////////
|
|
|
|
task sourceJar(type: Jar) {
|
|
|
|
description = "Creates a JAR that contains the source code."
|
|
|
|
|
|
|
|
from sourceSets.main.allSource
|
|
|
|
|
|
|
|
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
|
2018-06-30 23:22:05 +02:00
|
|
|
publishing {
|
|
|
|
publications {
|
2018-07-17 03:12:24 +02:00
|
|
|
licensing(MavenPublication) {
|
2018-06-30 23:22:05 +02:00
|
|
|
from components.java
|
|
|
|
|
2018-07-17 03:12:24 +02:00
|
|
|
artifact(javaDocJar)
|
|
|
|
artifact(sourceJar)
|
|
|
|
|
2018-06-30 23:22:05 +02:00
|
|
|
groupId project.group
|
|
|
|
artifactId project.ext.id
|
|
|
|
version project.version
|
|
|
|
|
|
|
|
pom {
|
2018-07-17 03:12:24 +02:00
|
|
|
name = project.ext.id
|
2018-06-30 23:22:05 +02:00
|
|
|
url = project.ext.url
|
|
|
|
description = project.description
|
|
|
|
|
|
|
|
issueManagement {
|
2018-07-17 04:01:51 +02:00
|
|
|
url = "${project.ext.url}/issues".toString()
|
2018-06-30 23:22:05 +02:00
|
|
|
system = 'Gitea Issues'
|
|
|
|
}
|
|
|
|
|
|
|
|
organization {
|
2018-07-17 03:12:24 +02:00
|
|
|
name = 'dorkbox, llc'
|
2018-06-30 23:22:05 +02:00
|
|
|
url = 'https://dorkbox.com'
|
|
|
|
}
|
|
|
|
|
|
|
|
developers {
|
|
|
|
developer {
|
|
|
|
name = 'dorkbox, llc'
|
|
|
|
email = 'email@dorkbox.com'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-17 03:12:24 +02:00
|
|
|
scm {
|
|
|
|
url = project.ext.url
|
|
|
|
connection = "scm:${project.ext.url}.git".toString()
|
|
|
|
}
|
|
|
|
|
2018-06-30 23:22:05 +02:00
|
|
|
// this plugin automates including the "license" section in the POM
|
|
|
|
// with license only specific information (name/url). Everything else
|
|
|
|
// must be explicitly added the POM
|
|
|
|
licenses {
|
|
|
|
license {
|
|
|
|
name = 'The Apache Software License, Version 2.0'
|
|
|
|
url = 'http://www.apache.org/licenses/LICENSE-2.0'
|
|
|
|
}
|
|
|
|
}
|
2018-07-17 03:12:24 +02:00
|
|
|
|
|
|
|
withXml {
|
|
|
|
def root = asNode()
|
|
|
|
|
|
|
|
// eliminate test-scoped dependencies (no need in maven central POMs)
|
|
|
|
root.dependencies.removeAll { dep ->
|
|
|
|
dep.scope == "test"
|
|
|
|
}
|
|
|
|
}
|
2018-06-30 23:22:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-07-17 03:12:24 +02:00
|
|
|
|
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
|
|
|
|
credentials {
|
|
|
|
username sonatypeUsername
|
|
|
|
password sonatypePassword
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nexusStaging {
|
|
|
|
username sonatypeUsername
|
|
|
|
password sonatypePassword
|
2018-06-30 23:22:05 +02:00
|
|
|
}
|
|
|
|
|
2018-07-17 03:12:24 +02:00
|
|
|
|
2018-07-17 21:12:12 +02:00
|
|
|
// we don't use maven with the plugin (it's uploaded separately to gradle plugins)
|
2018-07-17 03:12:24 +02:00
|
|
|
tasks.withType(PublishToMavenRepository) {
|
|
|
|
onlyIf {
|
|
|
|
repository == publishing.repositories.maven &&
|
|
|
|
publication == publishing.publications.licensing
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
signing {
|
|
|
|
required { hasProperty('sonatypeUsername') }
|
|
|
|
sign publishing.publications.licensing
|
|
|
|
}
|
|
|
|
|
2018-07-17 04:01:51 +02:00
|
|
|
// output the URL name in the console
|
|
|
|
project.afterEvaluate {
|
|
|
|
def URL = 'https://oss.sonatype.org/content/repositories/releases/'
|
|
|
|
def projectName = project.group.toString().replaceAll('\\.', '/')
|
|
|
|
def name = project.ext.id
|
|
|
|
def version = project.version
|
2018-07-17 03:12:24 +02:00
|
|
|
|
2018-07-17 04:01:51 +02:00
|
|
|
println("Maven URL: ${URL}${projectName}/${name}/${version}/")
|
2018-07-17 03:12:24 +02:00
|
|
|
}
|