Skip to content

Commit

Permalink
Publishing to Maven Central configured (nearly)
Browse files Browse the repository at this point in the history
  • Loading branch information
wadoon committed Jul 27, 2023
1 parent 29603af commit 40d836c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 31 deletions.
80 changes: 53 additions & 27 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ static def getDate() {
// The $BUILD_NUMBER is an environment variable set by Jenkins.
def build = System.env.BUILD_NUMBER == null ? "" : "-${System.env.BUILD_NUMBER}"

group = "org.key_project"
version = "2.11.0$build"
group = "org.key-project"
version = "2.12.0$build"

subprojects {
apply plugin: "java"
apply plugin: "java-library"
apply plugin: "maven-publish"
apply plugin: "signing" // GPG signing of artifacts, required by maven central
apply plugin: "idea"
apply plugin: "eclipse"

Expand Down Expand Up @@ -107,7 +108,7 @@ subprojects {
//options.verbose()
options.encoding = 'UTF-8'
if (JavaVersion.current().isJava9Compatible()) {
//options.addBooleanOption('html5', true)
options.addBooleanOption('html5', true)
}
}

Expand All @@ -133,7 +134,6 @@ subprojects {
}



test {
// Before we switched to JUnit 5, we used JUnit 4 with a customized discovery of test class.
// This discovery called AutoSuite and searched in the compiled classes. AutoSuite was
Expand Down Expand Up @@ -180,28 +180,28 @@ subprojects {
// The following two tasks can be used to execute main methods from the project
// The main class is set via "gradle -DmainClass=... execute --args ..."
// see https://stackoverflow.com/questions/21358466/gradle-to-execute-java-class-without-modifying-build-gradle
task execute(type:JavaExec) {
task execute(type: JavaExec) {
description 'Execute main method from the project. Set main class via "gradle -DmainClass=... execute --args ..."'
group "application"
mainClass.set(System.getProperty('mainClass'))
classpath = sourceSets.main.runtimeClasspath
}

task executeInTests(type:JavaExec) {
task executeInTests(type: JavaExec) {
description 'Execute main method from the project (tests loaded). Set main class via "gradle -DmainClass=... execute --args ..."'
group "application"
mainClass.set(System.getProperty('mainClass'))
classpath = sourceSets.test.runtimeClasspath
}

// findbugs { findbugsTest.enabled = false; ignoreFailures = true }
pmd {
pmd {
pmdTest.enabled = false
ignoreFailures = true
ignoreFailures = true
toolVersion = "6.53.0"
consoleOutput = false
rulesMinimumPriority = 5
ruleSets = ["category/java/errorprone.xml", "category/java/bestpractices.xml"]
ruleSets = ["category/java/errorprone.xml", "category/java/bestpractices.xml"]
}

task pmdMainChanged(type: Pmd) {
Expand All @@ -225,7 +225,7 @@ subprojects {
checkstyle {
toolVersion = "10.6.0"
ignoreFailures = true
configFile file("$rootDir/gradle/key_checks.xml")
configFile file("$rootDir/gradle/key_checks.xml")
showViolations = false // disable console output
}

Expand All @@ -249,9 +249,7 @@ subprojects {
outputLocation = file("build/reports/checkstyle/main_diff.xml")
}
}
}


}


// tasks.withType(FindBugs) {
Expand All @@ -260,13 +258,13 @@ subprojects {
// html.enabled = true
// }
// }
tasks.withType(Pmd) {
reports {
xml.getRequired().set(true)
html.getRequired().set(true)
}
}
tasks.withType(Pmd) {
reports {
xml.getRequired().set(true)
html.getRequired().set(true)
}
}

task sourcesJar(type: Jar) {
description = 'Create a jar file with the sources from this project'
from sourceSets.main.allJava
Expand All @@ -281,7 +279,7 @@ subprojects {

publishing {
publications {
gpr(MavenPublication) {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
Expand All @@ -296,6 +294,7 @@ subprojects {
url = "http://www.gnu.org/licenses/old-licenses/gpl-2.0.html"
}
}

developers {
developer {
id = 'key'
Expand All @@ -313,10 +312,31 @@ subprojects {
}
repositories {
maven {
if (project.version.endsWith("-SNAPSHOT")) {
name = "mavenSnapshot"
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
credentials(PasswordCredentials) {
println("username: ", ossrhUsername)
username = ossrhUsername
password = ossrhPassword
}
} else {
name = "mavenStaging"
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials(PasswordCredentials) {
println("username: " + ossrhPassword)
username = ossrhUsername
password = ossrhPassword
}
}
}

/*
maven { // deployment to git.key-project.org
name = "GitlabPackages"
url "https://git.key-project.org/api/v4/projects/35/packages/maven"
credentials(HttpHeaderCredentials) {
if(System.getenv("TOKEN") != null) {
if (System.getenv("TOKEN") != null) {
name = 'Private-Token'
value = System.getenv("TOKEN")
} else {
Expand All @@ -328,17 +348,23 @@ subprojects {
header(HttpHeaderAuthentication)
}
}
*/
}
}

signing {
useGpgCmd() // works better than the Java implementation, which requires PGP keyrings.
sign publishing.publications.mavenJava
}

license {//configures the license file header
header = file("$rootDir/gradle/header")

mapping {
//find styles here:
// http://code.mycila.com/license-maven-plugin/#supported-comment-types
java="SLASHSTAR_STYLE" // DOUBLESLASH_STYLE
javascript="SLASHSTAR_STYLE"
java = "SLASHSTAR_STYLE" // DOUBLESLASH_STYLE
javascript = "SLASHSTAR_STYLE"
}
mapping("key", "SLASHSTAR_STYLE")
}
Expand Down Expand Up @@ -475,10 +501,10 @@ def getChangedFiles() {
// Remove the status prefix
def files = new TreeSet<String>()
for (file in allFiles) {
if(file.length() > 1) {
if (file.length() > 1) {
def a = file.substring(1).trim()
if(! a.isBlank() ) {
files.add(("$rootDir/"+a).toString())
if (!a.isBlank()) {
files.add(("$rootDir/" + a).toString())
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions key.core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,4 @@ task generateRAPUnitTests(type: JavaExec) {
}
sourceSets.test.java.srcDirs("$buildDir/generated-src/rap/")


// @AW: Delete? weigl: depends: If want that gradle check validates everything then not.
// check.dependsOn << testProofRules << testRunAllProofs

sourcesJar.dependsOn(runAntlr4Jml, runAntlr4Key, compileJavacc, generateGrammarSource)
3 changes: 3 additions & 0 deletions key.ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ dependencies {

api 'org.dockingframes:docking-frames-common:1.1.3p1'
api 'org.dockingframes:docking-frames-core:1.1.3p1'
// change to if published on maven central
// api 'org.key-project:docking-frames-common:1.1.3p1'
// api 'org.key-project:docking-frames-core:1.1.3p1'

runtimeOnly project(":keyext.ui.testgen")
runtimeOnly project(":keyext.exploration")
Expand Down

0 comments on commit 40d836c

Please sign in to comment.