converted gradle build file from groovy dsl to kotlin dsl

pull/11/head
Stefan Feuerhahn 6 years ago
parent d1237d2e45
commit 42e855fce6

@ -1,231 +0,0 @@
plugins {
id("biz.aQute.bnd.builder") version "4.1.0"
id("com.diffplug.gradle.spotless") version "3.24.2" apply false
id("io.codearte.nexus-staging") version "0.20.0"
}
apply from: "configuration.gradle"
configure(allprojects) {
version = cfgVersion
}
nexusStaging {
packageGroup = cfgGroup
username = cfgRepositoryUser
password = cfgRepositoryPass
stagingProfileId = cfgStagingProfileId
}
configure(javaProjects) {
apply plugin: "java-library"
apply plugin: "eclipse"
apply plugin: "maven"
apply plugin: "signing"
apply plugin: "biz.aQute.bnd.builder"
apply plugin: "com.diffplug.gradle.spotless"
uploadArchives.enabled = false
group = cfgGroup
if (!project.properties.containsKey('cfgJavaVersion')) {
project.ext {
cfgJavaVersion = '8'
}
}
sourceCompatibility = cfgJavaVersion
targetCompatibility = cfgJavaVersion
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
testImplementation group: "org.junit.jupiter", name: "junit-jupiter", version: "5.5.1"
}
test {
useJUnitPlatform()
}
afterEvaluate {
jar {
inputs.property("moduleName", moduleName)
manifest {
version = project.version.replace("-", ".")
attributes('Automatic-Module-Name': moduleName)
}
}
}
spotless {
java {
googleJavaFormat()
}
}
tasks.withType(JavaCompile) {
doFirst {
if (sourceCompatibility == '7' && System.env.JDK7_HOME != null) {
options.fork = true
options.bootstrapClasspath = files("$System.env.JDK7_HOME/jre/lib/rt.jar")
}
}
}
task jarAll(type: Copy) {
dependsOn(configurations.default.getAllArtifacts().getBuildDependencies())
//only the jar file created:
from configurations.default.getAllArtifacts().getFiles()
if (cfgCopyDependencies) {
if (cfgCopyToRoot) {
into rootDir.getPath() + "/build/libs-all"
} else {
into "build/libs-all"
}
//includes all the dependencies:
from configurations.default
} else {
if (cfgCopyToRoot) {
into rootDir.getPath() + "/build/libs-all"
} else {
into "build/libs-all"
}
}
}
build.dependsOn { jarAll }
eclipse.pathVariables([GRADLE_USER_HOME: file(gradle.gradleUserHomeDir)])
tasks.eclipse.dependsOn(cleanEclipse)
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = "javadoc"
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
javadoc {
exclude "**/internal/**"
exclude "**/java-gen/**"
exclude "**/app/**"
if (Integer.valueOf(cfgJavaVersion) > 10) {
options.links "https://docs.oracle.com/en/java/javase/$cfgJavaVersion/docs/api/"
} else {
options.links "https://docs.oracle.com/javase/$cfgJavaVersion/docs/api/"
}
}
}
configure(repositoryProjects) {
uploadArchives.enabled = true
if (cfgSignPom) {
signing {
if (project.hasProperty("signing.keyId")) {
sign configurations.archives
}
}
}
uploadArchives {
repositories {
mavenDeployer {
if (cfgSignPom) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}
repository(url: cfgRepository) {
authentication(userName: cfgRepositoryUser, password: cfgRepositoryPass)
if (cfgRepository != null && System.getProperty("https.proxyHost") != null && ((System.getProperty("https.nonProxyHosts") == null) || !cfgRepository.contains(System.getProperty("https.nonProxyHosts")))) {
proxy(host: System.getProperty("https.proxyHost"), port: Integer.parseInt(System.getProperty("https.proxyPort")), type: "https")
}
}
snapshotRepository(url: cfgSnapshotRepository) {
authentication(userName: cfgRepositoryUser, password: cfgRepositoryPass)
if (cfgSnapshotRepository != null && System.getProperty("https.proxyHost") != null && ((System.getProperty("https.nonProxyHosts") == null) || !cfgSnapshotRepository.contains(System.getProperty("https.nonProxyHosts")))) {
proxy(host: System.getProperty("https.proxyHost"), port: Integer.parseInt(System.getProperty("https.proxyPort")), type: "https")
}
}
pom.project {
//additional pom information can be found in subproject build.gradle files
packaging "jar"
url "http://www.beanit.com/"
scm {
url "none"
connection "none"
}
developers {
developer {
id "beanit"
name "Beanit GmbH"
}
}
}
}
}
}
}
task javadocAll(type: Javadoc) {
source docProjects.collect {
project -> project.sourceSets.main.allJava
}
exclude "**/internal/**"
exclude "**/java-gen/**"
exclude "**/app/**"
destinationDir = new File(buildDir, "docs/javadoc-all")
classpath = files(distributionProjects.collect { project ->
project.sourceSets.main.compileClasspath
})
classpath += files(distributionProjects.collect { project ->
project.sourceSets.main.output
})
if (Integer.valueOf(cfgJavaVersion) > 10) {
options.links "https://docs.oracle.com/en/java/javase/$cfgJavaVersion/docs/api/"
} else {
options.links "https://docs.oracle.com/javase/$cfgJavaVersion/docs/api/"
}
}
tasks.withType(Tar) {
dependsOn(distributionProjects.build)
dependsOn(javadocAll)
compression = Compression.GZIP
destinationDir = file("build/distributions/")
}
task(tar, type: Tar) {
archiveName = project.name + "-" + project.version + ".tgz"
}

@ -0,0 +1,309 @@
plugins {
`java-library`
`maven-publish`
signing
eclipse
id("biz.aQute.bnd.builder") version "5.0.0"
id("com.diffplug.gradle.spotless") version "3.27.2"
id("io.codearte.nexus-staging") version "0.21.2"
}
var cfgJavaVersion = JavaVersion.VERSION_1_8
val sonatypeRepository: String? by project
val sonatypeSnapshotRepository: String? by project
val sonatypeUser: String? by project
val sonatypePass: String? by project
val sonatypeStagingProfileId: String? by project
//----------- project specific configuration start --------------------
val cfgVersion = "1.8.1-SNAPSHOT"
val cfgGroup = "com.beanit"
val cfgCopyToRoot = false
val cfgSignPom = true
val cfgRepository: String? = sonatypeRepository
val cfgSnapshotRepository: String? = sonatypeSnapshotRepository
val cfgRepositoryUser: String? = sonatypeUser
val cfgRepositoryPass: String? = sonatypePass
val cfgStagingProfileId: String? = sonatypeStagingProfileId
val javaProjects: Set<Project> = allprojects
val distributionProjects = javaProjects
val docProjects = javaProjects
val repositoryProjects = javaProjects
val cfgModuleName = "com.beanit.jasn1"
tasks.register<Tar>("tar") {
into(project.name) {
from("./") {
include("build.gradle.kts")
include("configuration.gradle.kts")
include("settings.gradle.kts")
include("LICENSE.txt")
include("doc/**")
include("bin/**")
include("gradle/wrapper/**")
include("gradlew")
include("gradlew.bat")
include("build/libs-all/**")
include("src/**")
include("asn1/**")
}
}
into(project.name + "/doc/") {
from("./build/docs/") {
include("javadoc/**")
}
}
}
//-----java root project configurations
dependencies {
implementation("com.beanit:jasn1:1.11.0")
implementation("com.toedter:jcalendar:1.4")
implementation("org.slf4j:slf4j-api:1.7.25")
runtimeOnly("ch.qos.logback:logback-classic:1.2.3")
}
project.extra["cfgModuleName"] = "com.beanit.openiec61850"
tasks["jar"].withConvention(aQute.bnd.gradle.BundleTaskConvention::class) {
bnd("""
Bundle-Name: OpenIEC61850
Bundle-SymbolicName: ${project.extra["cfgModuleName"]}
-exportcontents: !*.internal.*,*
Import-Package: com.beanit.jasn1.*,javax.net,*;resolution:=optional
""")
}
sourceSets {
main {
java {
setSrcDirs(listOf("src/main/java", "src/main/java-gen"))
}
}
}
publishing {
publications {
maybeCreate<MavenPublication>("mavenJava").pom {
name.set("OpenIEC61850")
description.set("OpenIEC61850 is a Java library implementing the IEC 61850 MMS communication standard for clients and servers.")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
}
}
//----------- project specific configuration end ---------------------
configure(allprojects) {
version = cfgVersion
group = cfgGroup
}
nexusStaging {
packageGroup = cfgGroup
username = cfgRepositoryUser
password = cfgRepositoryPass
stagingProfileId = cfgStagingProfileId
}
configure(javaProjects) {
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = "eclipse")
apply(plugin = "biz.aQute.bnd.builder")
apply(plugin = "com.diffplug.gradle.spotless")
tasks.publish {
enabled = false
}
repositories {
mavenCentral()
}
java {
sourceCompatibility = cfgJavaVersion
targetCompatibility = cfgJavaVersion
withSourcesJar()
withJavadocJar()
}
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.5.1")
}
tasks.test {
useJUnitPlatform()
}
afterEvaluate {
tasks.jar {
manifest {
attributes["Automatic-Module-Name"] = project.extra["cfgModuleName"]
}
}
}
spotless {
java {
googleJavaFormat()
}
}
tasks.register<Copy>("jarAll") {
from(configurations.runtimeClasspath) // all runtime dependencies
from(tasks.jar) // the jar file created
if (cfgCopyToRoot) {
into(rootDir.path + "/build/libs-all")
} else {
into("build/libs-all")
}
}
tasks.build {
dependsOn("jarAll")
}
eclipse.pathVariables(mapOf("GRADLE_USER_HOME" to file(gradle.gradleUserHomeDir)))
tasks.eclipse { dependsOn(tasks.cleanEclipse) }
tasks.javadoc {
exclude("**/internal/**")
exclude("**/java-gen/**")
exclude("**/app/**")
//linking Javadoc in version prior 9 does not work well because Javadoc uses html frames.
if (cfgJavaVersion.isJava9Compatible) {
if (cfgJavaVersion.isJava11Compatible) {
(options as StandardJavadocDocletOptions).links?.add("https://docs.oracle.com/en/java/javase/${cfgJavaVersion.majorVersion}/docs/api/")
} else {
(options as StandardJavadocDocletOptions).links?.add("https://docs.oracle.com/javase/${cfgJavaVersion.majorVersion}/docs/api/")
}
}
}
}
configure(repositoryProjects) {
tasks.publish {
enabled = true
}
}
configure(repositoryProjects) {
publishing {
publications {
val mvnPublication: MavenPublication = maybeCreate<MavenPublication>("mavenJava")
mvnPublication.from(components["java"])
mvnPublication.versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
mvnPublication.pom {
url.set("http://www.beanit.com/")
developers {
developer {
id.set("beanit")
name.set("Beanit GmbH")
}
}
scm {
connection.set("none")
url.set("none")
}
}
}
repositories {
maven {
val releasesRepoUrl = uri(cfgRepository ?: "")
val snapshotsRepoUrl = uri(cfgSnapshotRepository ?: "")
// val releasesRepoUrl = uri("$buildDir/repos/releases")
// val snapshotsRepoUrl = uri("$buildDir/repos/snapshots")
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
credentials {
username = cfgRepositoryUser
password = cfgRepositoryPass
}
}
}
}
if (cfgSignPom) {
signing {
sign(publishing.publications["mavenJava"])
}
}
}
tasks.register<Javadoc>("javadocAll") {
source(docProjects.map { project ->
project.sourceSets["main"].allJava
})
exclude("**/internal/**")
exclude("**/java-gen/**")
exclude("**/app/**")
setDestinationDir(File(buildDir, "docs/javadoc-all"))
classpath = files(distributionProjects.map { project ->
project.sourceSets["main"].compileClasspath
})
classpath += files(distributionProjects.map { project ->
project.sourceSets["main"].output
})
//linking Javadoc in version prior 9 does not work well because Javadoc uses html frames.
if (cfgJavaVersion.isJava9Compatible) {
if (cfgJavaVersion.isJava11Compatible) {
(options as StandardJavadocDocletOptions).links?.add("https://docs.oracle.com/en/java/javase/${cfgJavaVersion.majorVersion}/docs/api/")
} else {
(options as StandardJavadocDocletOptions).links?.add("https://docs.oracle.com/javase/${cfgJavaVersion.majorVersion}/docs/api/")
}
}
}
tasks.named<Tar>("tar") {
archiveFileName.set(project.name + "-" + project.version + ".tgz")
dependsOn(distributionProjects.map { "${it.path}:build" })
distributionProjects.forEach {
println("project: "
+ it.path)
}
dependsOn(tasks.named("javadocAll"))
compression = Compression.GZIP
destinationDirectory.set(File("build/distributions/"))
}

@ -1,112 +0,0 @@
project.ext {
cfgVersion = "1.8.1-SNAPSHOT"
cfgGroup = "com.beanit"
cfgCopyDependencies = true
cfgCopyToRoot = false
cfgSignPom = true
cfgJavaVersion = "8"
cfgRepository = project.properties.sonatypeRepository
cfgSnapshotRepository = project.properties.sonatypeSnapshotRepository
cfgRepositoryUser = project.properties.sonatypeUser
cfgRepositoryPass = project.properties.sonatypePass
cfgStagingProfileId = project.properties.sonatypeStagingProfileId
javaProjects = allprojects
distributionProjects = javaProjects
docProjects = javaProjects
repositoryProjects = javaProjects
}
tasks.withType(Tar) {
into(project.name) {
from("./") {
include "build.gradle"
include "configuration.gradle"
include "settings.gradle"
include "LICENSE.txt"
include "doc/**"
include "bin/**"
include "gradle/wrapper/**"
include "gradlew"
include "gradlew.bat"
include "build/libs-all/**"
include "src/**"
include "asn1/**"
}
}
into(project.name + "/doc/") {
from("./build/docs/") {
include "javadoc/**"
}
}
}
//------------------project specific configurations--------------------
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "maven"
apply plugin: "signing"
def projectName = "OpenIEC61850"
dependencies {
implementation group: "com.beanit", name: "jasn1", version: "1.11.0"
implementation group: "com.toedter", name: "jcalendar", version: "1.4"
implementation group: "org.slf4j", name: "slf4j-api", version: "1.7.25"
runtimeOnly group: "ch.qos.logback", name: "logback-classic", version: "1.2.3"
}
ext.moduleName = "com.beanit.openiec61850"
jar {
bnd("Bundle-Name": "OpenIEC61850",
"Bundle-SymbolicName": moduleName,
"-exportcontents": "!*.internal.*,*",
"Import-Package": "com.beanit.jasn1.*,javax.net,*;resolution:=optional")
}
sourceSets {
main {
java.srcDirs = ["src/main/java", "src/main/java-gen"]
}
}
uploadArchives {
repositories {
mavenDeployer {
pom.project {
name "OpenIEC61850"
description "OpenIEC61850 is a Java library implementing the IEC 61850 MMS communication standard for clients and servers."
licenses {
license {
name "Apache License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0"
distribution "repo"
}
}
}
}
}
}

Binary file not shown.

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

29
gradlew vendored

@ -154,19 +154,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@ -175,14 +175,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

3
gradlew.bat vendored

@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@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="-Xmx64m" "-Xms64m"

Loading…
Cancel
Save