Migrated build from groovy -> kotlin script
parent
6fddd4ee03
commit
cd093f7b14
137
build.gradle
137
build.gradle
|
@ -1,137 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
def propsFile = Paths.get("${projectDir}/../../gradle.properties").normalize()
|
||||
if (propsFile.toFile().canRead()) {
|
||||
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)}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url 'https://plugins.gradle.org/m2/' }
|
||||
}
|
||||
dependencies {
|
||||
// for plugin publishing
|
||||
classpath 'com.gradle.publish:plugin-publish-plugin:0.9.10'
|
||||
|
||||
// for license sources
|
||||
classpath 'gradle.plugin.com.dorkbox:Licensing:1.2.2'
|
||||
classpath 'gradle.plugin.com.dorkbox:Licensing:1.2.2:sources'
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'java-gradle-plugin'
|
||||
id 'maven-publish'
|
||||
id 'signing'
|
||||
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.2.60'
|
||||
}
|
||||
|
||||
// for publishing the plugin to gradle
|
||||
apply plugin: 'com.gradle.plugin-publish'
|
||||
apply plugin: 'com.dorkbox.Licensing'
|
||||
|
||||
project.description = 'Gradle Plugin to update version information and git tags within the Gradle project and java/kotlin files'
|
||||
project.group = 'com.dorkbox'
|
||||
project.version = '1.2'
|
||||
|
||||
project.ext.name = 'Version Update'
|
||||
project.ext.id = 'VersionUpdate'
|
||||
project.ext.url = 'https://git.dorkbox.com/dorkbox/VersionUpdate'
|
||||
project.ext.tags = ['version', 'versioning', 'semver', 'semantic-versioning']
|
||||
|
||||
licensing {
|
||||
license(License.APACHE_2) {
|
||||
author 'dorkbox, llc'
|
||||
url project.ext.url
|
||||
note 'Plugin to set version information in maven POM, java or kotlin files, and git tags'
|
||||
note """Git tag code based upon 'gradle-git-version', Copyright 2015, Palantir Technologies. https://github.com/palantir/gradle-git-version"""
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
setSrcDirs Collections.singletonList('src')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60'
|
||||
|
||||
implementation 'org.eclipse.jgit:org.eclipse.jgit:4.5.4+'
|
||||
implementation 'com.dorkbox:Version:1.0'
|
||||
|
||||
implementation 'org.slf4j:slf4j-api:1.7.25'
|
||||
runtime 'ch.qos.logback:logback-classic:1.1.6'
|
||||
compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
options.incremental = true
|
||||
}
|
||||
|
||||
tasks.withType(Jar) {
|
||||
duplicatesStrategy DuplicatesStrategy.FAIL
|
||||
|
||||
manifest {
|
||||
attributes['Implementation-Version'] = project.version
|
||||
attributes['Build-Date'] = Instant.now().toString()
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
////// Plugin Publishing + Release
|
||||
///////////////////////////////
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
Version {
|
||||
id = "${project.group}.${project.ext.id}"
|
||||
implementationClass = 'dorkbox.version.VersionPlugin'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pluginBundle {
|
||||
website = project.ext.url
|
||||
vcsUrl = project.ext.url
|
||||
|
||||
plugins {
|
||||
version {
|
||||
id = "${project.group}.${project.ext.id}"
|
||||
displayName = project.ext.name
|
||||
description = project.description
|
||||
tags = project.ext.tags
|
||||
version = project.version
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* 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 org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import java.nio.file.Paths
|
||||
import java.time.Instant
|
||||
import java.util.Properties
|
||||
import kotlin.reflect.full.declaredMemberProperties
|
||||
|
||||
plugins {
|
||||
java
|
||||
`java-gradle-plugin`
|
||||
|
||||
id("com.gradle.plugin-publish") version "0.10.0"
|
||||
id("com.dorkbox.Licensing") version "1.2.2"
|
||||
|
||||
kotlin("jvm") version "1.3.11"
|
||||
}
|
||||
|
||||
|
||||
println("Gradle ${project.gradle.gradleVersion}")
|
||||
|
||||
// load properties from custom location
|
||||
val propsFile = File("$projectDir/../../gradle.properties").normalize()
|
||||
if (propsFile.canRead()) {
|
||||
println("Loading custom property data from: $propsFile")
|
||||
|
||||
val props = Properties()
|
||||
props.load(propsFile.inputStream())
|
||||
props.forEach{(k, v) -> project.extra.set(k as String, v as String)}
|
||||
}
|
||||
|
||||
object Extras {
|
||||
// set for the project
|
||||
const val description = "Gradle Plugin to update version information and git tags within the Gradle project and java/kotlin files"
|
||||
const val group = "com.dorkbox"
|
||||
const val version = "1.4"
|
||||
|
||||
// set as project.ext
|
||||
const val name = "Version Update"
|
||||
const val id = "VersionUpdate"
|
||||
const val vendor = "Dorkbox LLC"
|
||||
const val url = "https://git.dorkbox.com/dorkbox/VersionUpdate"
|
||||
val tags = listOf("version", "versioning", "semver", "semantic-versioning")
|
||||
val buildDate = Instant.now().toString()
|
||||
}
|
||||
// assign everything to project or project.ext
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
description = Extras.description
|
||||
group = Extras.group
|
||||
version = Extras.version
|
||||
|
||||
|
||||
licensing {
|
||||
license(License.APACHE_2) {
|
||||
author("dorkbox, llc")
|
||||
url(Extras.url)
|
||||
note("Plugin to set version information in maven POM, java or kotlin files, and git tags")
|
||||
note("""Git tag code based upon 'gradle-git-version', Copyright 2015, Palantir Technologies. https://github.com/palantir/gradle-git-version""")
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
setSrcDirs(files("src"))
|
||||
|
||||
// want to include kotlin files for the source. 'setSrcDirs' resets includes...
|
||||
include("**/*.kt")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// the kotlin version is taken from the plugin, so it is not necessary to set it here
|
||||
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin")
|
||||
compileOnly("org.jetbrains.kotlin:kotlin-reflect")
|
||||
compile ("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
|
||||
implementation ("org.eclipse.jgit:org.eclipse.jgit:4.5.4+")
|
||||
implementation ("com.dorkbox:Version:1.0")
|
||||
|
||||
implementation ("org.slf4j:slf4j-api:1.7.25")
|
||||
runtime ("ch.qos.logback:logback-classic:1.1.6")
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = "UTF-8"
|
||||
options.isIncremental = true
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
|
||||
targetCompatibility = JavaVersion.VERSION_1_8.toString()
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||
}
|
||||
|
||||
|
||||
tasks.withType<Jar> {
|
||||
duplicatesStrategy = DuplicatesStrategy.FAIL
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
val wrapperUpdate by tasks.creating(Wrapper::class) {
|
||||
gradleVersion = "5.0"
|
||||
distributionUrl = distributionUrl.replace("bin", "all")
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
//////// Plugin Publishing + Release
|
||||
/////////////////////////////////
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("Version") {
|
||||
id = "${Extras.group}.${Extras.id}"
|
||||
implementationClass = "dorkbox.version.VersionPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pluginBundle {
|
||||
website = Extras.url
|
||||
vcsUrl = Extras.url
|
||||
|
||||
(plugins) {
|
||||
"Version" {
|
||||
id = "${Extras.group}.${Extras.id}"
|
||||
displayName = Extras.name
|
||||
description = Extras.description
|
||||
tags = Extras.tags
|
||||
version = Extras.version
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,4 +13,3 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
enableFeaturePreview('STABLE_PUBLISHING')
|
Loading…
Reference in New Issue