diff --git a/.gitignore b/.gitignore index 0a0ff0f1..a1b09435 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,9 @@ build/ bin/ libs/ +target/ +*/target/ + *.iws *.iml *.ipr diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 04b8a0af..00000000 --- a/build.gradle +++ /dev/null @@ -1,324 +0,0 @@ -// SPDX-FileCopyrightText: 2021 Paul Schaub -// -// SPDX-License-Identifier: Apache-2.0 - -buildscript { - - repositories { - - maven { - url "https://plugins.gradle.org/m2/" - } - mavenLocal() - mavenCentral() - } - dependencies { - classpath "gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.0" - } -} - -plugins { - id 'org.jetbrains.kotlin.jvm' version "1.8.10" - id 'com.diffplug.spotless' version '6.22.0' apply false -} - -apply from: 'version.gradle' - -allprojects { - apply plugin: 'java' - apply plugin: 'idea' - apply plugin: 'eclipse' - apply plugin: 'jacoco' - apply plugin: 'checkstyle' - apply plugin: 'kotlin' - apply plugin: 'com.diffplug.spotless' - - java { - targetCompatibility = JavaVersion.VERSION_1_8 - } - - compileJava { - options.release = 8 - } - - // Only generate jar for submodules - // without this we would generate an empty pgpainless.jar for the project root - // https://stackoverflow.com/a/25445035 - jar { - onlyIf { !sourceSets.main.allSource.files.isEmpty() } - } - - // checkstyle - checkstyle { - toolVersion = '10.12.1' - } - - spotless { - kotlin { - ktfmt().dropboxStyle() - } - } - - group 'org.pgpainless' - description = "Simple to use OpenPGP API for Java based on Bouncycastle" - version = shortVersion - - sourceCompatibility = javaSourceCompatibility - - repositories { - mavenCentral() - mavenLocal() - } - - // Reproducible Builds - tasks.withType(AbstractArchiveTask) { - preserveFileTimestamps = false - reproducibleFileOrder = true - - dirMode = 0755 - fileMode = 0644 - } - - // Compatibility of default implementations in kotlin interfaces with Java implementations. - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { - kotlinOptions { - freeCompilerArgs += ["-Xjvm-default=all-compatibility"] - } - } - - project.ext { - rootConfigDir = new File(rootDir, 'config') - gitCommit = getGitCommit() - isContinuousIntegrationEnvironment = Boolean.parseBoolean(System.getenv('CI')) - isReleaseVersion = !isSnapshot - signingRequired = !(isSnapshot || isContinuousIntegrationEnvironment) - sonatypeCredentialsAvailable = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword') - sonatypeSnapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots' - sonatypeStagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2' - } - - if (isSnapshot) { - version = version + '-SNAPSHOT' - } - def projectDirFile = new File("$projectDir") - if (!project.ext.isSnapshot && !'git describe --exact-match HEAD'.execute(null, projectDirFile).text.trim().equals(ext.shortVersion)) { - throw new InvalidUserDataException('Untagged version detected! Please tag every release.') - } - if (!version.endsWith('-SNAPSHOT') && version != 'git tag --points-at HEAD'.execute(null, projectDirFile).text.trim()) { - throw new InvalidUserDataException( - 'Tag mismatch detected, version is ' + version + ' but should be ' + - 'git tag --points-at HEAD'.execute(null, projectDirFile).text.trim()) - } - - jacoco { - toolVersion = "0.8.8" - } - - jacocoTestReport { - dependsOn test - sourceDirectories.setFrom(project.files(sourceSets.main.allSource.srcDirs)) - classDirectories.setFrom(project.files(sourceSets.main.output)) - reports { - xml.enabled true - } - } - - test { - useJUnitPlatform() - testLogging { - events "passed", "skipped", "failed" - exceptionFormat "full" - } - } -} - -subprojects { - apply plugin: 'maven-publish' - apply plugin: 'signing' - - task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource - } - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } - task testsJar(type: Jar, dependsOn: testClasses) { - classifier = 'tests' - from sourceSets.test.output - } - - publishing { - publications { - mavenJava(MavenPublication) { - from components.java - artifact sourcesJar - artifact javadocJar - artifact testsJar - pom { - name = 'PGPainless' - description = 'Simple to use OpenPGP API for Java based on Bouncycastle' - url = 'https://github.com/pgpainless/pgpainless' - inceptionYear = '2018' - - scm { - url = 'https://github.com/pgpainless/pgpainless' - connection = 'scm:https://github.com/pgpainless/pgpainless' - developerConnection = 'scm:git://github.com/pgpainless/pgpainless.git' - } - - licenses { - license { - name = 'The Apache Software License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution = 'repo' - } - } - - developers { - developer { - id = 'vanitasvitae' - name = 'Paul Schaub' - email = 'vanitasvitae@fsfe.org' - } - } - } - } - } - repositories { - if (sonatypeCredentialsAvailable) { - maven { - url isSnapshot ? sonatypeSnapshotUrl : sonatypeStagingUrl - credentials { - username = sonatypeUsername - password = sonatypePassword - } - } - } - } - } - - signing { - useGpgCmd() - required { signingRequired } - sign publishing.publications.mavenJava - } -} - -def getGitCommit() { - def projectDirFile = new File("$projectDir") - def dotGit = new File("$projectDir/.git") - if (!dotGit.isDirectory()) return 'non-git build' - - def cmd = 'git describe --always --tags --dirty=+' - def proc = cmd.execute(null, projectDirFile) - def gitCommit = proc.text.trim() - assert !gitCommit.isEmpty() - - def srCmd = 'git symbolic-ref --short HEAD' - def srProc = srCmd.execute(null, projectDirFile) - srProc.waitForOrKill(10 * 1000) - if (srProc.exitValue() == 0) { - // Only add the information if the git command was - // successful. There may be no symbolic reference for HEAD if - // e.g. in detached mode. - def symbolicReference = srProc.text.trim() - assert !symbolicReference.isEmpty() - gitCommit += "-$symbolicReference" - } - - gitCommit -} - -apply plugin: "com.github.kt3k.coveralls" -coveralls { - sourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs).files.absolutePath -} - -task jacocoRootReport(type: JacocoReport) { - dependsOn = subprojects.jacocoTestReport - sourceDirectories.setFrom(files(subprojects.sourceSets.main.allSource.srcDirs)) - classDirectories.setFrom(files(subprojects.sourceSets.main.output)) - executionData.setFrom(files(subprojects.jacocoTestReport.executionData)) - reports { - xml.enabled true - xml.destination file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml") - } - // We could remove the following setOnlyIf line, but then - // jacocoRootReport would silently be SKIPPED if something with - // the projectsWithUnitTests is wrong (e.g. a project is missing - // in there). - setOnlyIf { true } -} - -task javadocAll(type: Javadoc) { - def currentJavaVersion = JavaVersion.current() - if (currentJavaVersion.compareTo(JavaVersion.VERSION_1_9) >= 0) { - options.addStringOption("-release", "8"); - } - source subprojects.collect {project -> - project.sourceSets.main.allJava } - destinationDir = new File(buildDir, 'javadoc') - // Might need a classpath - classpath = files(subprojects.collect {project -> - project.sourceSets.main.compileClasspath}) - options.linkSource = true - options.use = true - options.links = [ - "https://docs.oracle.com/javase/${sourceCompatibility.getMajorVersion()}/docs/api/", - ] as String[] -} - -if (JavaVersion.current().isJava8Compatible()) { - tasks.withType(Javadoc) { - // The '-quiet' as second argument is actually a hack, - // since the one paramater addStringOption doesn't seem to - // work, we extra add '-quiet', which is added anyway by - // gradle. See https://github.com/gradle/gradle/issues/2354 - // See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363) - // for information about the -Xwerror option. - options.addStringOption('Xwerror', '-quiet') - } -} - -/** - * Fetch sha256 checksums of artifacts published to maven central. - * - * Example: gradle -Prelease=1.3.13 mavenCentralChecksums - */ -task mavenCentralChecksums() { - description 'Fetch and display checksums for artifacts published to Maven Central' - String ver = project.hasProperty('release') ? release : shortVersion - doLast { - Process p = "curl -f https://repo1.maven.org/maven2/org/pgpainless/pgpainless-core/${ver}/pgpainless-core-${ver}.jar.sha256".execute() - if (p.waitFor() == 0) { - print p.text.trim() - println " pgpainless-core/build/libs/pgpainless-core-${ver}.jar" - } - - p = "curl -f https://repo1.maven.org/maven2/org/pgpainless/pgpainless-sop/${ver}/pgpainless-sop-${ver}.jar.sha256".execute() - if (p.waitFor() == 0) { - print p.text.trim() - println " pgpainless-sop/build/libs/pgpainless-sop-${ver}.jar" - } - - p = "curl -f https://repo1.maven.org/maven2/org/pgpainless/pgpainless-cli/${ver}/pgpainless-cli-${ver}-all.jar.sha256".execute() - if (p.waitFor() == 0) { - print p.text.trim() - println " pgpainless-cli/build/libs/pgpainless-cli-${ver}-all.jar" - } - - p = "curl -f https://repo1.maven.org/maven2/org/pgpainless/pgpainless-cli/${ver}/pgpainless-cli-${ver}.jar.sha256".execute() - if (p.waitFor() == 0) { - print p.text.trim() - println " pgpainless-cli/build/libs/pgpainless-cli-${ver}.jar" - } - - p = "curl -f https://repo1.maven.org/maven2/org/pgpainless/hsregex/${ver}/hsregex-${ver}.jar.sha256".execute() - if (p.waitFor() == 0) { - print p.text.trim() - println " hsregex/build/libs/hsregex-${ver}.jar" - } - } -} diff --git a/pgpainless-cli/build.gradle b/pgpainless-cli/build.gradle deleted file mode 100644 index d6550139..00000000 --- a/pgpainless-cli/build.gradle +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-FileCopyrightText: 2021 Paul Schaub -// -// SPDX-License-Identifier: Apache-2.0 - -plugins { - id 'application' - id "com.github.johnrengelman.shadow" version "6.1.0" -} - -dependencies { - - testImplementation(project(":pgpainless-core")) - - testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion" - - // implementation "ch.qos.logback:logback-core:1.2.6" - // We want logback logging in tests and in the app - testImplementation "ch.qos.logback:logback-classic:$logbackVersion" - implementation "ch.qos.logback:logback-classic:$logbackVersion" - - implementation(project(":pgpainless-sop")) - implementation "org.pgpainless:sop-java-picocli:$sopJavaVersion" - - // https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305 - implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2' -} - -mainClassName = 'org.pgpainless.cli.PGPainlessCLI' - -application { - mainClass = mainClassName -} -/** -jar { - duplicatesStrategy(DuplicatesStrategy.EXCLUDE) - manifest { - attributes 'Main-Class': "$mainClassName" - } - - from { - configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } - } { - exclude "META-INF/*.SF" - exclude "META-INF/*.DSA" - exclude "META-INF/*.RSA" - } -} - */ - -run { - // https://stackoverflow.com/questions/59445306/pipe-into-gradle-run - standardInput = System.in - // https://discuss.gradle.org/t/how-can-i-provide-command-line-args-to-application-started-with-gradle-run/6474/5 - if (project.hasProperty("appArgs")) { - args Eval.me(appArgs) - } -} - -// tasks."jar".dependsOn(":pgpainless-core:assemble", ":pgpainless-sop:assemble") diff --git a/pgpainless-cli/pom.xml b/pgpainless-cli/pom.xml new file mode 100644 index 00000000..ad5c7511 --- /dev/null +++ b/pgpainless-cli/pom.xml @@ -0,0 +1,74 @@ + + + 4.0.0 + + org.pgpainless + pgpainless-parent + 1.7.3-SNAPSHOT + + + pgpainless-cli + + + org.pgpainless.cli.PGPainlessCLI + + + + + ch.qos.logback + logback-classic + + + org.pgpainless + pgpainless-sop + ${project.version} + + + org.pgpainless + sop-java-picocli + + + com.google.code.findbugs + jsr305 + runtime + + + + org.junit.jupiter + junit-jupiter-api + test + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + ${maven.assembly.plugin.version} + + + jar-with-dependencies + + + + ${mainClass} + + + + + + make-assembly + package + + single + + + + + + + + \ No newline at end of file diff --git a/pgpainless-core/build.gradle b/pgpainless-core/build.gradle deleted file mode 100644 index bab6ecf1..00000000 --- a/pgpainless-core/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-FileCopyrightText: 2021 Paul Schaub -// -// SPDX-License-Identifier: Apache-2.0 - -plugins { - id 'java-library' -} - -dependencies { - // JUnit - testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion" - testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion" - - // Mocking Components - testImplementation "org.mockito:mockito-core:$mockitoVersion" - - // Logging - api "org.slf4j:slf4j-api:$slf4jVersion" - testImplementation "ch.qos.logback:logback-classic:$logbackVersion" - - // Bouncy Castle - api "org.bouncycastle:bcprov-jdk18on:$bouncyCastleVersion" - api "org.bouncycastle:bcpg-jdk18on:$bouncyPgVersion" - // api(files("../libs/bcpg-jdk18on-1.70.jar")) - - // @Nullable, @Nonnull annotations - implementation "com.google.code.findbugs:jsr305:3.0.2" -} - -// https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_modular_auto -tasks.named('jar') { - manifest { - attributes('Automatic-Module-Name': 'org.pgpainless.core') - } -} diff --git a/pgpainless-core/pom.xml b/pgpainless-core/pom.xml new file mode 100644 index 00000000..4d346d03 --- /dev/null +++ b/pgpainless-core/pom.xml @@ -0,0 +1,112 @@ + + + 4.0.0 + + org.pgpainless + pgpainless-parent + 1.7.3-SNAPSHOT + + + pgpainless-core + jar + + + + org.jetbrains.kotlin + kotlin-stdlib + compile + + + org.pgpainless + sop-java + + + org.bouncycastle + bcprov-jdk18on + + + org.bouncycastle + bcpg-jdk18on + + + org.bouncycastle + bcutil-jdk18on + + + + org.slf4j + slf4j-api + + + + com.google.code.findbugs + jsr305 + compile + + + + + org.jetbrains.kotlin + kotlin-test-junit5 + test + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-params + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.junit.jupiter + junit-jupiter + ${junit.version} + test + + + + + org.mockito + mockito-core + test + + + org.testng + testng + 7.10.2 + test + + + + + + + + + kotlin-maven-plugin + org.jetbrains.kotlin + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.apache.maven.plugins + maven-assembly-plugin + + + + + \ No newline at end of file diff --git a/pgpainless-sop/build.gradle b/pgpainless-sop/build.gradle deleted file mode 100644 index aa0f5993..00000000 --- a/pgpainless-sop/build.gradle +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-FileCopyrightText: 2021 Paul Schaub -// -// SPDX-License-Identifier: Apache-2.0 -import org.apache.tools.ant.filters.* -plugins { - id 'java-library' -} - -group 'org.pgpainless' - -repositories { - mavenCentral() - mavenLocal() -} - -dependencies { - testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion" - testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion" - - // Logging - testImplementation "ch.qos.logback:logback-classic:$logbackVersion" - - // Depend on "shared" sop-java test suite (fixtures are turned into tests by inheritance inside test sources) - testImplementation(testFixtures("org.pgpainless:sop-java:$sopJavaVersion")) - - implementation(project(":pgpainless-core")) - api "org.pgpainless:sop-java:$sopJavaVersion" - - implementation "com.google.code.findbugs:jsr305:3.0.2" -} - -processResources { - filter ReplaceTokens, tokens: [ - "project.version": project.version.toString() - ] -} - -test { - useJUnitPlatform() - environment("test.implementation", "sop.testsuite.pgpainless.PGPainlessSopInstanceFactory") -} - -// https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_modular_auto -tasks.named('jar') { - manifest { - attributes('Automatic-Module-Name': 'org.pgpainless.sop') - } -} diff --git a/pgpainless-sop/pom.xml b/pgpainless-sop/pom.xml new file mode 100644 index 00000000..8e21eb3d --- /dev/null +++ b/pgpainless-sop/pom.xml @@ -0,0 +1,73 @@ + + + 4.0.0 + + org.pgpainless + pgpainless-parent + 1.7.3-SNAPSHOT + + + pgpainless-sop + jar + + + + org.pgpainless + sop-java + compile + + + org.pgpainless + sop-java-testfixtures + 10.0.3-SNAPSHOT + test + + + org.pgpainless + pgpainless-core + ${project.version} + + + com.google.code.findbugs + jsr305 + runtime + + + + + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.2 + + + sop.testsuite.pgpainless.PGPainlessSopInstanceFactory + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.apache.maven.plugins + maven-assembly-plugin + + + + \ No newline at end of file diff --git a/pgpainless-sop/src/main/resources/pgpainless-sop.properties b/pgpainless-sop/src/main/resources/pgpainless-sop.properties index d71e996b..c663fa18 100644 --- a/pgpainless-sop/src/main/resources/pgpainless-sop.properties +++ b/pgpainless-sop/src/main/resources/pgpainless-sop.properties @@ -1 +1 @@ -pgpainless-sop-version=@project.version@ \ No newline at end of file +pgpainless-sop-version=${project.version} diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..745ab315 --- /dev/null +++ b/pom.xml @@ -0,0 +1,251 @@ + + + 4.0.0 + + org.pgpainless + pgpainless-parent + 1.7.3-SNAPSHOT + pom + + + pgpainless-core + pgpainless-sop + pgpainless-cli + + + PGPainless + Simple to use OpenPGP API for Java based on Bouncycastle + https://github.com/pgpainless/pgpainless + 2018 + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + vanitasvitae + Paul Schaub + vanitasvitae@fsfe.org + + + + scm:https://github.com/pgpainless/pgpainless + scm:git://github.com/pgpainless/pgpainless.git + https://github.com/pgpainless/pgpainless + + + + 1.8 + 1.8.10 + + ${java.version} + ${java.version} + UTF-8 + 3.3.0 + 1.78.1 + 10.0.3 + 1.7.36 + 5.8.2 + 4.5.1 + + 2023-01-01T00:00:00Z + + + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test-junit5 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-reflect + ${kotlin.version} + + + + + org.bouncycastle + bcprov-jdk18on + ${bouncycastle.version} + + + org.bouncycastle + bcpg-jdk18on + ${bouncycastle.version} + + + org.bouncycastle + bcutil-jdk18on + ${bouncycastle.version} + + + + + org.pgpainless + sop-java + ${sop-java.version} + + + org.pgpainless + sop-java-testfixtures + ${sop-java.version} + + + org.pgpainless + sop-java-picocli + ${sop-java.version} + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + ch.qos.logback + logback-classic + 1.5.0 + test + + + + + + + + + + + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + process-sources + + compile + + + + src/main/java + src/main/kotlin + + + + + test-compile + process-test-sources + + test-compile + + + + src/test/java + src/test/kotlin + src/test/resources + + + + + + ${java.version} + + -Xjvm-default=all-compatibility + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + default-compile + none + + + default-testCompile + none + + + compile + compile + + compile + + + + testCompile + test-compile + + testCompile + + + + + ${java.version} + ${java.version} + + + + + + diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index aea19392..00000000 --- a/settings.gradle +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-FileCopyrightText: 2021 Paul Schaub -// -// SPDX-License-Identifier: CC0-1.0 - -rootProject.name = 'PGPainless' - -include 'pgpainless-core', - 'pgpainless-sop', - 'pgpainless-cli' - diff --git a/version.gradle b/version.gradle deleted file mode 100644 index 07c66ec5..00000000 --- a/version.gradle +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-FileCopyrightText: 2021 Paul Schaub -// -// SPDX-License-Identifier: CC0-1.0 - -allprojects { - ext { - shortVersion = '1.7.3' - isSnapshot = true - pgpainlessMinAndroidSdk = 10 - javaSourceCompatibility = 1.8 - bouncyCastleVersion = '1.78.1' - bouncyPgVersion = bouncyCastleVersion - junitVersion = '5.8.2' - logbackVersion = '1.5.13' - mockitoVersion = '4.5.1' - slf4jVersion = '1.7.36' - sopJavaVersion = '10.0.3' - } -}