Skip to content

Commit

Permalink
Engine publishing config
Browse files Browse the repository at this point in the history
  • Loading branch information
Duzhinsky committed Aug 31, 2023
1 parent 025ddd7 commit f50d261
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 88 deletions.
81 changes: 80 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
`java-library`
`test-report-aggregation`
`maven-publish`
signing
}

val testReportTask = tasks.register<TestReport>("testReport") {
Expand Down Expand Up @@ -34,4 +36,81 @@ allprojects {
tasks.test {
useJUnitPlatform()
}
}

project.afterEvaluate {
if (project.plugins.hasPlugin("maven-publish")) {
configurePublishedProject(this)
}
}
}

fun configurePublishedProject(project: Project) {
project.java {
withJavadocJar()
withSourcesJar()
}

project.signing {
sign(publishing.publications)
}

project.publishing {
publications.withType<MavenPublication>().forEach() { configureMavenPublication(it) }
repositories {
maven {
name = "ghPackages"
url = uri("https://maven.pkg.github.com/SuduIDE/protogen")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
maven {
name = "sonatype"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2")
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
}
}


fun configureMavenPublication(publication: MavenPublication) {
publication.pom {
url = "https://github.com/SuduIDE/protogen"
organization {
name = "com.github.SuduIDE"
url = "https://github.com/SuduIDE"
}
issueManagement {
system = "GitHub"
url = "https://github.com/SuduIDE/protogen/issues"
}
licenses {
license {
name = "The Apache License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
scm {
url = "https://github.com/SuduIDE/protogen"
connection = "scm:https://github.com/SuduIDE/protogen.git"
developerConnection = "scm:git://github.com/SuduIDE/protogen.git"
}
developers {
developer {
id = "Duzhinsky"
name = "Dmitrii Duzhinskii"
email = "[email protected]"
}
}
}

publication.groupId = project.group.toString()
publication.version = project.version.toString()
publication.artifact(tasks.findByName("sourcesJar"))
publication.artifact(tasks.findByName("javadocJar"))
}
37 changes: 16 additions & 21 deletions generator/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
plugins {
java
`maven-publish`
signing
id("com.github.johnrengelman.shadow") version "8.1.1"
}

repositories {
mavenCentral()
publishing {
publications {
create<MavenPublication>("maven") {
pom {
description = "protoc plugin of protogen"
name = "protogen-engine"
}
artifactId = "protogen-engine"
artifact(tasks.shadowJar) {
classifier = "jvm"
}
}
}
}

dependencies {
Expand All @@ -13,22 +26,4 @@ dependencies {

implementation("org.apache.commons:commons-lang3:3.13.0")
implementation("commons-io:commons-io:2.13.0")
}

tasks.jar {
dependsOn(":options:build")
dependsOn(":javapoet:build")
archiveBaseName.set("protogen-generator")
manifest {
// To debug uncomment the line below, and run generator. It'll generate a descriptor_dump file in generated folder
// Then comment the line back and run org.sudu.protogen.protoc.Main from IDEA with descriptor_dump absolute path as a parameter
// attributes.put("Main-Class", "org.sudu.protogen.protoc.plugin.dump.DumpGenerator")
attributes.put("Main-Class", "org.sudu.protogen.protoc.Main")
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
archiveClassifier.set("jdk")
from(configurations.runtimeClasspath.get().map({ if (it.isDirectory()) it else zipTree(it) }))
{
exclude("META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA")
}
}
2 changes: 1 addition & 1 deletion generator/src/main/java/org/sudu/protogen/utils/Name.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Name {
/**
* Adjust a class generatedName to follow the JavaBean spec.
* - capitalize the first letter
* - remove embedded underscores & capitalize the following letter
* - remove embedded underscores and capitalize the following letter
* - capitalize letter after a number
*
* @param name method generatedName
Expand Down
66 changes: 1 addition & 65 deletions options/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,81 +4,17 @@ plugins {
signing
}

java {
withJavadocJar()
withSourcesJar()
}

signing {
sign(publishing.publications)
}

publishing {
publications {
create<MavenPublication>("maven") {
pom {

description = "Options for protogen tool. Use it as protogen scope dependency"
name = "protogen-options"
url = "https://github.com/SuduIDE/protogen"
organization {
name = "com.github.SuduIDE"
url = "https://github.com/SuduIDE"
}
issueManagement {
system = "GitHub"
url = "https://github.com/SuduIDE/protogen/issues"
}
licenses {
license {
name = "The Apache License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
scm {
url = "https://github.com/SuduIDE/protogen"
connection = "scm:https://github.com/SuduIDE/protogen.git"
developerConnection = "scm:git://github.com/SuduIDE/protogen.git"
}
developers {
developer {
id = "Duzhinsky"
name = "Dmitrii Duzhinskii"
email = "[email protected]"
}
}
}

groupId = project.group.toString()
artifactId = "protogen-options"
version = project.version.toString()

from(components["java"])
artifact(tasks.jar)
}
}

repositories {
maven {
name = "ghPackages"
url = uri("https://maven.pkg.github.com/SuduIDE/protogen")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
maven {
name = "sonatype"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2")
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
}

repositories {
mavenCentral()
}

protobuf {
Expand Down

0 comments on commit f50d261

Please sign in to comment.