diff --git a/build.gradle b/build.gradle index 783c53f3..ca5b5030 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,5 @@ subprojects { apply plugin: 'groovy' - apply plugin: 'application' dependencies { compile 'net.i2p:i2p:0.9.40' diff --git a/core/build.gradle b/core/build.gradle index aa44e324..5aeaf4cb 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,3 +1,4 @@ +apply plugin : 'application' mainClassName = 'com.muwire.core.Core' applicationDefaultJvmArgs = ['-Djava.util.logging.config.file=logging.properties'] dependencies { diff --git a/gui/build.gradle b/gui/build.gradle new file mode 100644 index 00000000..e21faab2 --- /dev/null +++ b/gui/build.gradle @@ -0,0 +1,139 @@ +buildscript { + repositories { + jcenter() + mavenLocal() + } + + dependencies { + classpath 'org.codehaus.griffon:gradle-griffon-plugin:2.15.1' + classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2' + classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0' + classpath 'org.gradle.api.plugins:gradle-izpack-plugin:0.2.3' + classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' + classpath 'com.github.cr0:gradle-macappbundle-plugin:3.1.0' + classpath 'org.kordamp.gradle:stats-gradle-plugin:0.2.2' + classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0' + classpath 'de.gliderpilot.gradle.jnlp:gradle-jnlp-plugin:1.2.5' + classpath 'net.nemerosa:versioning:2.6.1' + } +} + +apply plugin: 'org.codehaus.griffon.griffon' +apply plugin: 'net.nemerosa.versioning' + +Date buildTimeAndDate = new Date() +ext { + buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate) + buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate) + macosx = System.getProperty('os.name').contains('Mac OS') +} + +griffon { + disableDependencyResolution = false + includeGroovyDependencies = true + version = '2.15.1' + toolkit = 'swing' + applicationProperties = [ + 'build_date' : buildDate, + 'build_time' : buildTime, + 'build_revision': versioning.info.commit + ] +} + +mainClassName = 'com.muwire.gui.Launcher' + +apply from: 'gradle/publishing.gradle' +apply from: 'gradle/code-coverage.gradle' +apply from: 'gradle/code-quality.gradle' +apply from: 'gradle/integration-test.gradle' +// apply from: 'gradle/package.gradle' +apply from: 'gradle/docs.gradle' +apply plugin: 'com.github.johnrengelman.shadow' +apply plugin: 'org.kordamp.gradle.stats' +apply plugin: 'com.github.ben-manes.versions' +apply plugin: 'com.github.kt3k.coveralls' + +dependencies { + compile project(":core") + compile "org.codehaus.griffon:griffon-guice:${griffon.version}" + + runtime "org.slf4j:slf4j-simple:${slf4jVersion}" + + testCompile "org.codehaus.griffon:griffon-fest-test:${griffon.version}" + testCompile "org.spockframework:spock-core:${spockVersion}" + testCompile('org.awaitility:awaitility-groovy:3.1.0') { + exclude group: 'org.codehaus.groovy', module: 'groovy-all' + } + testCompile "org.codehaus.groovy:groovy-all:${groovyVersion}" +} + +task sourceJar(type: Jar) { + group 'Build' + description 'An archive of the source code' + classifier 'sources' + from sourceSets.main.allSource +} + +tasks.withType(JavaCompile) { + sourceCompatibility = project.sourceCompatibility + targetCompatibility = project.targetCompatibility +} + +tasks.withType(GroovyCompile) { + sourceCompatibility = project.sourceCompatibility + targetCompatibility = project.targetCompatibility +} + +import com.github.jengelman.gradle.plugins.shadow.transformers.* +import java.text.SimpleDateFormat + +ext.backgroundImage = 'i2plogo.png' + +shadowJar { + transform(ServiceFileTransformer) + transform(ServiceFileTransformer) { + path = 'META-INF/griffon' + } + transform(ServiceFileTransformer) { + path = 'META-INF/types' + } + transform(PropertiesFileTransformer) { + paths = [ + 'META-INF/editors/java.beans.PropertyEditor' + ] + } +} + +startScripts { + doLast { + if (!macosx) unixScript.text = unixScript.text.replaceAll('"(-Xdock:(name|icon)=)([^"]*?)(")', ' ') + windowsScript.text = windowsScript.text.replaceAll('"(-Xdock:(name|icon)=)([^"]*?)(")', ' ') + } +} + +if (hasProperty('debugRun') && ((project.debugRun as boolean))) { + run { + jvmArgs '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005' + } +} + +task jacocoRootMerge(type: org.gradle.testing.jacoco.tasks.JacocoMerge, dependsOn: [test, jacocoTestReport, jacocoIntegrationTestReport]) { + executionData = files(jacocoTestReport.executionData, jacocoIntegrationTestReport.executionData) + destinationFile = file("${buildDir}/jacoco/root.exec") +} + +task jacocoRootReport(dependsOn: jacocoRootMerge, type: JacocoReport) { + group = 'Reporting' + description = 'Generate Jacoco coverage reports after running all tests.' + executionData file("${buildDir}/jacoco/root.exec") + sourceDirectories = files(sourceSets.main.allSource.srcDirs) + classDirectories = files(sourceSets.main.output) + reports { + csv.enabled = false + xml.enabled = true + html.enabled = true + html.destination = file("${buildDir}/reports/jacoco/root/html") + xml.destination = file("${buildDir}/reports/jacoco/root/root.xml") + } +} + diff --git a/gui/gradle/code-coverage.gradle b/gui/gradle/code-coverage.gradle new file mode 100644 index 00000000..a7a46756 --- /dev/null +++ b/gui/gradle/code-coverage.gradle @@ -0,0 +1,18 @@ +apply plugin: 'jacoco' + +jacoco { + toolVersion = '0.7.9' +} + +jacocoTestReport { + group = 'Reporting' + description = 'Generate Jacoco coverage reports after running tests.' + additionalSourceDirs = project.files(sourceSets.main.allSource.srcDirs) + sourceDirectories = project.files(sourceSets.main.allSource.srcDirs) + classDirectories = project.files(sourceSets.main.output) + reports { + xml.enabled = true + csv.enabled = false + html.enabled = true + } +} \ No newline at end of file diff --git a/gui/gradle/code-quality.gradle b/gui/gradle/code-quality.gradle new file mode 100644 index 00000000..3ff02a2d --- /dev/null +++ b/gui/gradle/code-quality.gradle @@ -0,0 +1,70 @@ +apply plugin: 'jdepend' +apply plugin: 'checkstyle' +apply plugin: 'com.github.hierynomus.license' + +def configDir = new File(buildscript.sourceFile.parentFile.parentFile, 'config') +ext.checkstyleConfigDir = "$configDir/checkstyle" + +checkstyle { + toolVersion = '6.0' + configFile = new File(checkstyleConfigDir, 'checkstyle.xml') + configProperties.checkstyleConfigDir = checkstyleConfigDir +} + +if (project.hasProperty('findBugsEnabled') && project.findBugsEnabled.toBoolean()) { + apply plugin: 'findbugs' + findbugs { + toolVersion = '3.0.0' + sourceSets = [sourceSets.main] + ignoreFailures = true + reportsDir = file("$project.buildDir/reports/findbugs") + effort = 'max' + reportLevel = 'high' + } + + findbugsMain { + reports { + xml.enabled = false + html.enabled = true + } + } + + findbugsTest { + reports { + xml.enabled = false + html.enabled = true + } + } +} + +jdepend { + toolVersion = '2.9.1' + sourceSets = [sourceSets.main] + ignoreFailures = true + reportsDir = file("$project.buildDir/reports/jdepend") +} + +license { + header = rootProject.file('config/HEADER') + strictCheck = true + ignoreFailures = true + mapping { + java = 'SLASHSTAR_STYLE' + groovy = 'SLASHSTAR_STYLE' + } + ext.year = '2018' + exclude '**/*.png' +} + +licenseTest { + source -= sourceSets.test.resources +} + +if (project.plugins.hasPlugin('groovy')) { + apply plugin: 'codenarc' + + codenarc { + ignoreFailures = true + configFile = file("$configDir/codenarc/codenarc.groovy") + } +} diff --git a/gui/gradle/docs.gradle b/gui/gradle/docs.gradle new file mode 100644 index 00000000..0ca118c7 --- /dev/null +++ b/gui/gradle/docs.gradle @@ -0,0 +1,62 @@ +javadoc { + excludes = ['**/*.html', 'META-INF/**', '**/*.groovy'] + + options.use = true + options.splitIndex = true + options.encoding = 'UTF-8' + options.author = true + options.version = true + options.windowTitle = "$project.name $project.version API" + options.docTitle = "$project.name $project.version API" + options.links 'https://www.slf4j.org/apidocs/' + options.links 'https://junit.org/junit4/javadoc/latest/' + options.links 'https://aalmiray.github.io/jsr-305/apidocs/' + options.links 'https://javax-inject.github.io/javax-inject/api/' + options.links 'https://docs.oracle.com/javase/8/docs/api/' + options.links 'https://docs.oracle.com/javase/8/javafx/api/' + options.links 'https://aalmiray.github.io/jipsy/apidocs/' + options.links 'https://aalmiray.github.io/gipsy/apidocs/' + options.links 'http://griffon-framework.org/guide/latest/api/' + + doLast { task -> + copy { + into task.destinationDir + from rootProject.file('src/javadoc/resources/img/griffon.ico'), + rootProject.file('src/javadoc/resources/css/stylesheet.css') + } + copy { + into file("${task.destinationDir}/resources") + from rootProject.file('src/javadoc/resources/img/') + } + } +} + +project.plugins.withId('groovy') { + groovydoc { + use = true + source = project.sourceSets.main.allSource + classpath = javadoc.classpath + windowTitle = "$project.name $project.version API" + docTitle = "$project.name $project.version API" + header = "$project.name $project.version API" + includePrivate = false + + link 'https://www.slf4j.org/apidocs/', 'org.slf4j.' + link 'https://junit.org/junit4/javadoc/latest/', 'org.junit.', 'junit.' + link 'https://aalmiray.github.io/jsr-305/apidocs/', 'javax.annotation.' + link 'https://javax-inject.github.io/javax-inject/api/', 'javax.inject.' + link 'https://docs.oracle.com/javase/8/docs/api/', 'java.', 'org.xml.', 'javax.', 'org.w3c.' + link 'https://docs.oracle.com/javase/8/javafx/api/', 'javafx' + link 'https://aalmiray.github.io/jipsy/apidocs/', 'org.kordamp.jipsy' + link 'https://aalmiray.github.io/gipsy/apidocs/', 'org.kordamp.gipsy' + link 'http://griffon-framework.org/guide/latest/api/', 'griffon.', 'org.codehaus.griffon.' + + doLast { task -> + copy { + into task.destinationDir + from rootProject.file('src/javadoc/resources/img/griffon.ico') + rename 'griffon.ico', 'groovy.ico' + } + } + } +} \ No newline at end of file diff --git a/gui/gradle/integration-test.gradle b/gui/gradle/integration-test.gradle new file mode 100644 index 00000000..5a0ef76a --- /dev/null +++ b/gui/gradle/integration-test.gradle @@ -0,0 +1,63 @@ +configurations { + integrationTestCompile { + extendsFrom testCompile + } + integrationTestRuntime { + extendsFrom integrationTestCompile, testRuntime + } +} + +sourceSets { + integrationTest { + if (file('src/integration-test/java').exists()) { + java.srcDirs file('src/integration-test/java') + } + if (file('src/integration-test/groovy').exists()) { + groovy.srcDirs file('src/integration-test/groovy') + } + resources.srcDir file('src/integration-test/resources') + compileClasspath += sourceSets.main.output + compileClasspath += configurations.compileOnly + compileClasspath += configurations.testCompileOnly + runtimeClasspath += compileClasspath + } +} + +idea { + module { + scopes.TEST.plus += [configurations.integrationTestCompile] + scopes.TEST.plus += [configurations.integrationTestRuntime] + testSourceDirs += sourceSets.integrationTest.allSource.srcDirs + } +} + +task integrationTest(type: Test, dependsOn: jar) { + testClassesDirs = sourceSets.integrationTest.output.classesDirs + classpath = sourceSets.integrationTest.runtimeClasspath + reports.html.enabled = false +} + +task integrationTestReport(type: TestReport) { + destinationDir = file("${buildDir}/reports/integration-tests") + reportOn integrationTest.binResultsDir +} + +integrationTest.mustRunAfter test +integrationTest.finalizedBy integrationTestReport +integrationTestReport.dependsOn integrationTest +check.dependsOn integrationTestReport + +task jacocoIntegrationTestReport(dependsOn: integrationTest, type: JacocoReport) { + group = 'Reporting' + description = 'Generate Jacoco coverage reports after running integration tests.' + executionData file("${buildDir}/jacoco/integrationTest.exec") + sourceDirectories = files(sourceSets.main.allSource.srcDirs) + classDirectories = files(sourceSets.main.output) + reports { + csv.enabled = false + xml.enabled = true + html.enabled = true + html.destination = file("${buildDir}/reports/jacoco/integration-test/html") + xml.destination = file("${buildDir}/reports/jacoco/integration-test/jacocoIntegrationTestReport.xml") + } +} \ No newline at end of file diff --git a/gui/gradle/package.gradle b/gui/gradle/package.gradle new file mode 100644 index 00000000..bf384127 --- /dev/null +++ b/gui/gradle/package.gradle @@ -0,0 +1,70 @@ +apply plugin: 'izpack' +if (macosx) apply plugin: 'com.github.cr0.macappbundle' + +dependencies { + izpack 'org.codehaus.izpack:izpack-standalone-compiler:4.3.5' +} + +task prepareIzpack(type: Copy, dependsOn: installDist) { + destinationDir = file("$buildDir/install/izpack") + from('src/main/izpack/resources') { + into 'resources' + } + into('binary') { + from installDist.destinationDir + } +} + +izPackCreateInstaller.dependsOn prepareIzpack +izPackCreateInstaller.doFirst { + ant.chmod(dir: "$buildDir/install/izpack/binary/bin", excludes: '*.bat', perm: 'ugo+x') +} + +izpack { + baseDir = file("$buildDir/install/izpack") + installFile = file('src/main/izpack/install.xml') + outputFile = file("$buildDir/distributions/${project.name}-${version}-installer.jar") + compression = 'deflate' + compressionLevel = 9 + appProperties = [ + 'app.group' : 'Applications', + 'app.name' : project.name, + 'app.title' : project.name, + 'app.version' : project.version, + 'app.subpath' : "${project.name}-${project.version}", + 'app.binary' : project.name, + 'app.java.version': targetCompatibility + ] +} + +if (macosx) { + File javaHome = new File(System.properties['java.home']) + javaHome = javaHome.name == 'jre' ? javaHome.parentFile : javaHome + + macAppBundle { + jreHome = javaHome.absolutePath + mainClassName = project.mainClassName + icon = 'src/media/griffon.icns' + javaProperties.put('apple.laf.useScreenMenuBar', 'true') + } +} + +if (!project.hasProperty('keyAlias')) ext.keyAlias = '' +if (!project.hasProperty('keystorePwd')) ext.keystorePwd = '' + +if (keyAlias || keystorePwd) { + apply plugin: 'de.gliderpilot.jnlp' + jnlp { + useVersions = true + withXml { + information { + title project.name + vendor project.group ?: project.name + } + security { + 'all-permissions'() + } + } + signJarParams = [alias: keyAlias, storepass: keystorePwd] + } +} diff --git a/gui/gradle/publishing.gradle b/gui/gradle/publishing.gradle new file mode 100644 index 00000000..57eec288 --- /dev/null +++ b/gui/gradle/publishing.gradle @@ -0,0 +1,13 @@ + +jar { + manifest { + attributes( + 'Built-By' : System.properties['user.name'], + 'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()), + 'Build-Revision' : versioning.info.commit, + 'Created-By' : "Gradle ${gradle.gradleVersion}", + 'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})", + 'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}" + ) + } +} \ No newline at end of file diff --git a/gui/gradle/wrapper/gradle-wrapper.jar b/gui/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..91ca28c8 Binary files /dev/null and b/gui/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gui/gradle/wrapper/gradle-wrapper.properties b/gui/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..16d28051 --- /dev/null +++ b/gui/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gui/griffon-app/resources/i2plogo.png b/gui/griffon-app/resources/i2plogo.png new file mode 100644 index 00000000..809d3005 Binary files /dev/null and b/gui/griffon-app/resources/i2plogo.png differ diff --git a/host-cache/build.gradle b/host-cache/build.gradle index 75ed482c..77a32826 100644 --- a/host-cache/build.gradle +++ b/host-cache/build.gradle @@ -1 +1,2 @@ +apply plugin : 'application' mainClassName = 'com.muwire.hostcache.HostCache' diff --git a/pinger/build.gradle b/pinger/build.gradle index 32c364c6..dd7bb3c6 100644 --- a/pinger/build.gradle +++ b/pinger/build.gradle @@ -1 +1,2 @@ +apply plugin: 'application' mainClassName = 'com.muwire.pinger.Pinger' diff --git a/settings.gradle b/settings.gradle index 5f24f330..7e4e2a59 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,4 @@ include 'pinger' include 'host-cache' include 'core' +include 'gui'