diff --git a/build.gradle b/build.gradle index 2b8fd32..c60a0a7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,60 +1,38 @@ -buildscript { - repositories { - maven { - url "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath group: "org.asciidoctor", name: "asciidoctorj-pdf", version: "1.5.0-alpha.16" - classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:4.0.0" - } -} - plugins { - id "org.asciidoctor.convert" version "1.5.6" - id "net.saliman.cobertura" version "2.5.1" + id("biz.aQute.bnd.builder") version "4.1.0" + id("com.diffplug.gradle.spotless") version "3.19.0" apply false + id("io.codearte.nexus-staging") version "0.20.0" } -apply plugin: "org.asciidoctor.convert" apply from: "configuration.gradle" -asciidoctor { - backends = ["pdf", "html5"] - attributes "stylesheet": "openmuc-asciidoc.css", - "toc2": "left", - "sampleSrc": file("src/sample/java"), - "source-highlighter": "coderay", - "pdf-stylesdir": "./", - "pdf-style": "pdf" - - resources { - from("$sourceDir") { - include "images/**" - } - } -} - configure(allprojects) { version = cfgVersion } +nexusStaging { + packageGroup = cfgGroup + username = cfgRepositoryUser + password = cfgRepositoryPass + stagingProfileId = cfgStagingProfileId +} + configure(javaProjects) { apply plugin: "java" apply plugin: "eclipse" - apply plugin: "osgi" apply plugin: "maven" apply plugin: "signing" apply plugin: "biz.aQute.bnd.builder" - apply plugin: 'net.saliman.cobertura' - + apply plugin: "com.diffplug.gradle.spotless" + uploadArchives.enabled = false group = cfgGroup if (!project.properties.containsKey('cfgJavaVersion')) { project.ext { - cfgJavaVersion = '1.7' + cfgJavaVersion = '1.8' } } @@ -67,7 +45,6 @@ configure(javaProjects) { } sourceSets { - sample itest { compileClasspath += sourceSets.main.runtimeClasspath } @@ -83,20 +60,20 @@ configure(javaProjects) { version = project.version.replace("-", ".") } } - cobertura { - dependencies { - testCompile 'org.slf4j:slf4j-simple:1.6.1' - } - coverageFormats = ['html', 'xml'] - coverageIgnoreTrivial = false - coverageIgnores = ['org.slf4j.Logger.*'] - coverageExcludes = ['.*\\.app\\..*', '.*\\.cli-app\\..*', '.*\\.sample\\..*'] - coverageReportDir = new File("$buildDir/reports/cobertura") - coverageTestTasks { - project.tasks.withType(Test).matching { it.name == 'test' } + spotless { + java { + googleJavaFormat() } + } + tasks.withType(JavaCompile) { + doFirst { + if (sourceCompatibility == '1.7' && System.env.JDK7_HOME != null) { + options.fork = true + options.bootstrapClasspath = files("$System.env.JDK7_HOME/jre/lib/rt.jar") + } + } } task jarAll(type: Copy) { @@ -121,7 +98,6 @@ configure(javaProjects) { } } - build.dependsOn { asciidoctor } build.dependsOn { jarAll } eclipse.pathVariables([GRADLE_USER_HOME: file(gradle.gradleUserHomeDir)]) @@ -185,11 +161,10 @@ configure(repositoryProjects) { } pom.project { - //additional pom information can be found in subproject build.gradle files packaging "jar" - url "http://www.openmuc.org/" + url "http://www.beanit.com/" scm { url "none" @@ -198,8 +173,8 @@ configure(repositoryProjects) { developers { developer { - id "openmuc" - name "OpenMUC Team" + id "beanit" + name "Beanit GmbH" } } } @@ -229,46 +204,9 @@ task javadocAll(type: Javadoc) { }) } - -task writeSettings { - doLast { - Writer out = new OutputStreamWriter(new FileOutputStream("build/settings.gradle")) - out.write("include ") - boolean first = true - for (Project myproject : distributionProjects) { - if (!myproject.getProjectDir().equals(getProjectDir())) { - if (first == true) { - first = false - } else { - out.write ", " - } - out.write '"' + myproject.name + '"' - } - } - out.write "\n\n" - - for (Project myproject : distributionProjects) { - if (myproject.getProjectDir().equals(getProjectDir())) { - continue - } - println myproject.name - out.write 'project(":' + myproject.name + '").projectDir = file("' + myproject.getProjectDir().toString().substring((int) (getProjectDir().toString().size() + 1)) + '")\n' - } - - out.close() - } -} - -task buildDistProjects { - dependsOn(distributionProjects.build) -} - tasks.withType(Tar) { - - dependsOn(writeSettings) dependsOn(distributionProjects.build) dependsOn(javadocAll) - dependsOn(asciidoctor) compression = Compression.GZIP @@ -279,7 +217,3 @@ task(tar, type: Tar) { archiveName = project.name + "-" + project.version + ".tgz" } -task(tarFull, type: Tar) { - dependsOn(tar) - archiveName = project.name + "-" + project.version + "_full.tgz" -} diff --git a/configuration.gradle b/configuration.gradle index 1f5f75a..e66836b 100644 --- a/configuration.gradle +++ b/configuration.gradle @@ -2,7 +2,7 @@ project.ext { cfgVersion = "1.7.1-SNAPSHOT" - cfgGroup = "org.openmuc" + cfgGroup = "com.beanit" cfgCopyDependencies = true @@ -10,6 +10,8 @@ project.ext { cfgSignPom = true + cfgJavaVersion = "1.7" + cfgRepository = project.properties.sonatypeRepository cfgSnapshotRepository = project.properties.sonatypeSnapshotRepository @@ -18,6 +20,8 @@ project.ext { cfgRepositoryPass = project.properties.sonatypePass + cfgStagingProfileId = project.properties.sonatypeStagingProfileId + javaProjects = allprojects distributionProjects = javaProjects @@ -33,9 +37,10 @@ tasks.withType(Tar) { from("./") { include "build.gradle" include "configuration.gradle" - include "license/**" - include "doc/CHANGELOG.txt" - include "run-scripts/**" + include "settings.gradle" + include "LICENSE.txt" + include "doc/**" + include "bin/**" include "gradle/wrapper/**" include "gradlew" include "gradlew.bat" @@ -44,20 +49,6 @@ tasks.withType(Tar) { include "asn1/**" } - - if (name.equals("tar")) { - exclude "**/dependencies/**/src" - } - - } - - into(project.name + "/doc/user-guide/") { - from("./build/asciidoc/html5/") { - include "**" - } - from("./build/asciidoc/pdf/") { - include "*.pdf" - } } into(project.name + "/doc/") { @@ -73,30 +64,28 @@ tasks.withType(Tar) { apply plugin: "java" apply plugin: "eclipse" -apply plugin: "osgi" apply plugin: "maven" apply plugin: "signing" -def projectName = 'OpenIEC61850' +def projectName = "OpenIEC61850" dependencies { - compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25' - compile group: 'com.beanit', name: 'jasn1', version: '1.11.0' - compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' - compile group: 'com.toedter', name: 'jcalendar', version: '1.4' + compile group: "org.slf4j", name: "slf4j-api", version: "1.7.25" + compile group: "com.beanit", name: "jasn1", version: "1.11.0" + compile group: "ch.qos.logback", name: "logback-classic", version: "1.2.3" + compile group: "com.toedter", name: "jcalendar", version: "1.4" } jar { - manifest { - name = projectName - instruction 'Export-Package', '!*.internal.*,*' - instruction 'Import-Package', 'org.openmuc.jasn1.*,javax.net,*;resolution:=optional' - } + bnd("Bundle-Name": "OpenIEC61850", + "Bundle-SymbolicName": "com.beanit.openiec61850", + "-exportcontents": "!*.internal.*,*", + "Import-Package": "com.beanit.jasn1.*,javax.net,*;resolution:=optional") } sourceSets { main { - java.srcDirs = ['src/main/java', 'src/main/java-gen'] + java.srcDirs = ["src/main/java", "src/main/java-gen"] } } @@ -104,16 +93,14 @@ uploadArchives { repositories { mavenDeployer { pom.project { - name projectName - packaging 'jar' - description 'OpenIEC61850 is a library implementing the IEC 61850 MMS communication standard (client and server).' - url 'http://www.openmuc.org/' + 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' + name "Apache License, Version 2.0" + url "http://www.apache.org/licenses/LICENSE-2.0" + distribution "repo" } } diff --git a/src/main/java/com/beanit/openiec61850/DataSet.java b/src/main/java/com/beanit/openiec61850/DataSet.java index d0e2c5d..f3d00dc 100644 --- a/src/main/java/com/beanit/openiec61850/DataSet.java +++ b/src/main/java/com/beanit/openiec61850/DataSet.java @@ -126,8 +126,7 @@ public final class DataSet implements Iterable { int slash = dataSetReference.indexOf('/'); String domainID = dataSetReference.substring(0, slash); - String itemID = - dataSetReference.substring(slash + 1).replace('.', '$'); + String itemID = dataSetReference.substring(slash + 1).replace('.', '$'); ObjectName.DomainSpecific domainSpecificObjectName = new ObjectName.DomainSpecific(); domainSpecificObjectName.setDomainID(new Identifier(domainID.getBytes())); diff --git a/src/test/java/com/beanit/openiec61850/integrationtests/ClientServerITest.java b/src/test/java/com/beanit/openiec61850/integrationtests/ClientServerITest.java index 5d66d99..44f6aca 100644 --- a/src/test/java/com/beanit/openiec61850/integrationtests/ClientServerITest.java +++ b/src/test/java/com/beanit/openiec61850/integrationtests/ClientServerITest.java @@ -45,7 +45,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; -import javax.naming.ConfigurationException; import org.junit.Assert; import org.junit.Test; @@ -112,8 +111,8 @@ public class ClientServerITest extends Thread implements ServerEventListener, Cl @Test public void testClientServerCom() - throws IOException, ServiceError, javax.naming.ConfigurationException, - SclParseException, InterruptedException { + throws IOException, ServiceError, javax.naming.ConfigurationException, SclParseException, + InterruptedException { clientSap.setTSelRemote(new byte[] {0, 1}); clientSap.setTSelLocal(new byte[] {0, 0}); diff --git a/src/test/java/com/beanit/openiec61850/integrationtests/ClientServerITest2.java b/src/test/java/com/beanit/openiec61850/integrationtests/ClientServerITest2.java index 47ad750..c6befba 100644 --- a/src/test/java/com/beanit/openiec61850/integrationtests/ClientServerITest2.java +++ b/src/test/java/com/beanit/openiec61850/integrationtests/ClientServerITest2.java @@ -33,7 +33,6 @@ import java.net.InetAddress; import java.util.Arrays; import java.util.Collections; import java.util.List; -import javax.naming.ConfigurationException; import org.junit.Assert; import org.junit.Test; @@ -100,8 +99,8 @@ public class ClientServerITest2 extends Thread implements ServerEventListener, C @Test public void testClientServerCom() - throws IOException, ServiceError, javax.naming.ConfigurationException, - SclParseException, InterruptedException { + throws IOException, ServiceError, javax.naming.ConfigurationException, SclParseException, + InterruptedException { clientSap.setTSelRemote(new byte[] {0, 1}); clientSap.setTSelLocal(new byte[] {0, 0}); diff --git a/src/test/java/com/beanit/openiec61850/integrationtests/ReportingTest.java b/src/test/java/com/beanit/openiec61850/integrationtests/ReportingTest.java index 4b23e2b..20a1fbb 100644 --- a/src/test/java/com/beanit/openiec61850/integrationtests/ReportingTest.java +++ b/src/test/java/com/beanit/openiec61850/integrationtests/ReportingTest.java @@ -33,7 +33,6 @@ import com.beanit.openiec61850.ServiceError; import com.beanit.openiec61850.Urcb; import java.io.IOException; import java.net.InetAddress; -import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; import org.junit.After; @@ -59,8 +58,7 @@ public class ReportingTest implements ClientEventListener { private int reportCounter = 0; @Before - public void startServerAndClient() - throws SclParseException, IOException, ServiceError { + public void startServerAndClient() throws SclParseException, IOException, ServiceError { startServer(); startClient(); }