Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Jreleaser configuration and clean up build script #115

Merged
merged 5 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 85 additions & 74 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,30 @@
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsTask
import com.adarshr.gradle.testlogger.TestLoggerExtension
import org.jreleaser.model.Active

plugins {
`java-library`
`maven-publish`
checkstyle
jacoco
id("com.github.spotbugs") version "5.0.14"
id("com.gradle.plugin-publish") version "1.2.0"
id("com.adarshr.test-logger") version "3.2.0"
id("com.gradle.plugin-publish") version "1.2.1" apply false
id("org.jreleaser") version "1.9.0"
}

// The root project doesn't produce a JAR.
tasks["jar"].enabled = false

val pluginVersion = project.file("VERSION").readText().replace(System.lineSeparator(), "")
allprojects {
group = "software.amazon.smithy"
group = "software.amazon.smithy.gradle"
version = pluginVersion
}
println("Smithy Gradle version: '${pluginVersion}'")

// JReleaser publishes artifacts from a local staging repository, rather than maven local.
// https://jreleaser.org/guide/latest/examples/maven/staging-artifacts.html#_gradle
val stagingDirectory = "$buildDir/staging"

subprojects {
val subproject = this
Expand Down Expand Up @@ -69,7 +72,6 @@ subprojects {
}

apply(plugin = "com.adarshr.test-logger")

configure<TestLoggerExtension> {
showExceptions = true
showStackTraces = true
Expand All @@ -87,12 +89,6 @@ subprojects {
logLevel = LogLevel.LIFECYCLE
}

// Reusable license copySpec
val licenseSpec = copySpec {
from("${project.rootDir}/LICENSE")
from("${project.rootDir}/NOTICE")
}

dependencies {
implementation("software.amazon.smithy:smithy-model:[1.0, 2.0[")
implementation("software.amazon.smithy:smithy-build:[1.0, 2.0[")
Expand All @@ -105,28 +101,22 @@ subprojects {
testImplementation(project(":integ-test-utils"))
}

if (subproject.name != "integ-test-utils") {
// Set up tasks that build source and javadoc jars.
tasks.register<Jar>("sourcesJar") {
metaInf.with(licenseSpec)
from(sourceSets.main.get().allJava)
archiveClassifier.set("sources")
}

tasks.register<Jar>("javadocJar") {
metaInf.with(licenseSpec)
from(tasks.javadoc)
archiveClassifier.set("javadoc")
}
// Reusable license copySpec
val licenseSpec = copySpec {
from("${project.rootDir}/LICENSE")
from("${project.rootDir}/NOTICE")
}

// Configure jars to include license related info
tasks.jar {
if (subproject.name != "integ-test-utils") {
// Configure all jars to include license info
tasks.withType<Jar>() {
metaInf.with(licenseSpec)
manifest {
attributes["Automatic-Module-Name"] = "software.amazon.smithy.gradle"
}
}

/*
* Configure integration tests
* ====================================================
*/
sourceSets {
create("it") {
compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
Expand All @@ -150,55 +140,28 @@ subprojects {
}

/*
* Maven
* Common plugin settings
* ====================================================
*
* Publish to Maven central.
*/
apply(plugin = "maven-publish")

publishing {
publications {
create<MavenPublication>("pluginMaven") {
pom {
description.set(subproject.description)
url.set("https://github.com/smithy-lang/smithy-gradle-plugin")
licenses {
license {
name.set("Apache License 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("smithy")
name.set("Smithy")
organization.set("Amazon Web Services")
organizationUrl.set("https://aws.amazon.com")
roles.add("developer")
}
}
scm {
url.set("https://github.com/smithy-lang/smithy-gradle-plugin.git")
}
}
}
}

repositories {
mavenLocal()
mavenCentral()
}
apply(plugin = "com.gradle.plugin-publish")
configure<GradlePluginDevelopmentExtension> {
website.set("https://smithy.io")
vcsUrl.set("https://github.com/smithy-lang/smithy-gradle-plugin")
}

/*
* Common plugin settings
* Staging repository
* ====================================================
*
* Configure publication to staging repo for jreleaser
*/
gradlePlugin {
website.set("https://smithy.io")
vcsUrl.set("https://github.com/smithy-lang/smithy-gradle-plugin")
configure<PublishingExtension> {
repositories {
maven {
name = "stagingRepository"
url = uri(stagingDirectory)
}
}
}

/*
Expand All @@ -208,7 +171,6 @@ subprojects {
* Apply CheckStyle to source files but not tests.
*/
apply(plugin = "checkstyle")

tasks["checkstyleTest"].enabled = false
tasks["checkstyleIt"].enabled = false

Expand All @@ -219,10 +181,8 @@ subprojects {
* Create code coverage reports after running tests.
*/
apply(plugin = "jacoco")

// Always run the jacoco test report after testing.
tasks["test"].finalizedBy(tasks["jacocoTestReport"])

// Configure jacoco to generate an HTML report.
tasks.jacocoTestReport {
reports {
Expand Down Expand Up @@ -261,4 +221,55 @@ subprojects {
}


/*
* Jreleaser (https://jreleaser.org) config.
*/
jreleaser {
dryrun = false

// Used for creating a tagged release, uploading files and generating changelog.
// In the future we can set this up to push release tags to GitHub, but for now it's
// set up to do nothing.
// https://jreleaser.org/guide/latest/reference/release/index.html
release {
generic {
enabled = true
skipRelease = true
}
}

// Used to announce a release to configured announcers.
// https://jreleaser.org/guide/latest/reference/announce/index.html
announce {
active = Active.NEVER
}

// Signing configuration.
// https://jreleaser.org/guide/latest/reference/signing.html
signing {
active = Active.ALWAYS
armored = true
}

// Configuration for deploying to Maven Central.
// https://jreleaser.org/guide/latest/examples/maven/maven-central.html#_gradle
deploy {
maven {
nexus2 {
create("maven-central") {
active = Active.ALWAYS
url = "https://aws.oss.sonatype.org/service/local"
snapshotUrl = "https://aws.oss.sonatype.org/content/repositories/snapshots"
closeRepository.set(false)
releaseRepository.set(false)
stagingRepositories.add(stagingDirectory)
}
}
}
}
}

repositories {
mavenLocal()
mavenCentral()
}
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rootProject.name = "smithy-gradle"

include("smithy-base-plugin")
include("smithy-jar-plugin")
include("smithy-base")
include("smithy-jar")
include("integ-test-utils")
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import org.apache.tools.ant.filters.ReplaceTokens

description = "This plugin sets up the basic capabilities necessary for building Smithy models." +
"Applying this plugin will create the basic source sets and configurations needed for smithy" +


description = "This plugin sets up the basic capabilities necessary for building Smithy models. " +
"Applying this plugin will create the basic source sets and configurations needed for Smithy " +
"projects. It will also create a smithy build task that will build and validate all the " +
"smithy models in the project."
"Smithy models in the project."

gradlePlugin {
plugins {
create("smithy-base-plugin") {
id = "software.amazon.smithy.gradle.smithy-base"
id = "${group}.smithy-base"
displayName = "Smithy Gradle Base Plugin"
description = project.description
implementationClass = "software.amazon.smithy.gradle.SmithyBasePlugin"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
description = "Adds built Smithy files to an existing jar task such as that created" +
"by the Java or Kotlin plugins. The smithy-jar plugin also adds build metadata" +
"and tags to the JAR's MANIFEST. The smithy-jar plugin applies the smithy-base" +
description = "Adds built Smithy files to an existing jar task such as that created " +
"by the Java or Kotlin plugins. The smithy-jar plugin also adds build metadata " +
"and tags to the JAR's MANIFEST. The smithy-jar plugin applies the smithy-base " +
"plugin when it is applied."

gradlePlugin {
plugins {
create("smithy-jar-plugin") {
id = "software.amazon.smithy.gradle.smithy-jar"
id = "${group}.smithy-jar"
displayName = "Smithy Gradle Jar Packaging Plugin"
description = project.description
implementationClass = "software.amazon.smithy.gradle.SmithyJarPlugin"
Expand All @@ -16,5 +16,5 @@ gradlePlugin {
}

dependencies {
implementation(project(":smithy-base-plugin"))
implementation(project(":smithy-base"))
}
Loading