Skip to content

Commit

Permalink
Extract build logic to convention plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandens committed Nov 27, 2022
1 parent a14000a commit 7f0925e
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 86 deletions.
13 changes: 13 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
}

dependencies {
implementation("com.gradle.publish:plugin-publish-plugin:1.1.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0-Beta")
implementation("com.netflix.nebula:nebula-publishing-plugin:19.0.0")
}
Empty file added buildSrc/settings.gradle.kts
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import org.gradle.kotlin.dsl.`java-gradle-plugin`
import org.gradle.kotlin.dsl.`maven-publish`
import org.gradle.kotlin.dsl.version

plugins {
`java-gradle-plugin`
`maven-publish`
id("com.gradle.plugin-publish")
id("org.jetbrains.kotlin.jvm")
id("com.netflix.nebula.maven-apache-license")
}

repositories {
mavenCentral()
gradlePluginPortal()
}

pluginBundle {
website = "https://www.ryandens.com"
vcsUrl = "https://github.com/ryandens/javaagent-gradle-plugin"
}

tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.allWarningsAsErrors = true
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

// Add a source set for the functional test suite
val functionalTestSourceSet = sourceSets.create("functionalTest") {
}

gradlePlugin.testSourceSets(functionalTestSourceSet)
configurations["functionalTestImplementation"].extendsFrom(configurations["testImplementation"])

// Add a task to run the functional tests
val functionalTest by tasks.registering(Test::class) {
testClassesDirs = functionalTestSourceSet.output.classesDirs
classpath = functionalTestSourceSet.runtimeClasspath
}

tasks.check {
// Run the functional tests as part of `check`
dependsOn(functionalTest)
}

dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
}
44 changes: 2 additions & 42 deletions otel/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,44 +1,19 @@
plugins {
`java-gradle-plugin`
`maven-publish`
id("com.gradle.plugin-publish") version "1.1.0"
id("org.jetbrains.kotlin.jvm") version "1.8.0-Beta"
id("com.netflix.nebula.maven-apache-license") version "19.0.0"
}

repositories {
mavenCentral()
gradlePluginPortal()
id("com.ryandens.plugin-conventions")
}

pluginBundle {
website = "https://www.ryandens.com"
vcsUrl = "https://github.com/ryandens/javaagent-gradle-plugin"
tags = listOf("otel", "instrumentation", "observability")
}

dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation(project(":plugin"))
implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
testImplementation(platform("org.junit:junit-bom:5.8.2"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.junit.jupiter:junit-jupiter-params")
}

tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.allWarningsAsErrors = true
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

gradlePlugin {
plugins {
create("JavaagentOTelModificationPlugin") {
Expand All @@ -51,21 +26,6 @@ gradlePlugin {
}
}

// Add a source set for the functional test suite
val functionalTestSourceSet = sourceSets.create("functionalTest") {
}

gradlePlugin.testSourceSets(functionalTestSourceSet)
configurations["functionalTestImplementation"].extendsFrom(configurations["testImplementation"])

// Add a task to run the functional tests
val functionalTest by tasks.registering(Test::class) {
testClassesDirs = functionalTestSourceSet.output.classesDirs
classpath = functionalTestSourceSet.runtimeClasspath
tasks.named<Test>("functionalTest") {
useJUnitPlatform()
}

tasks.check {
// Run the functional tests as part of `check`
dependsOn(functionalTest)
}
45 changes: 1 addition & 44 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
plugins {
`java-gradle-plugin`
`maven-publish`
id("com.gradle.plugin-publish") version "1.1.0"
id("org.jetbrains.kotlin.jvm") version "1.8.0-Beta"
id("com.netflix.nebula.maven-apache-license") version "19.0.0"
}

repositories {
mavenCentral()
gradlePluginPortal()
id("com.ryandens.plugin-conventions")
}

pluginBundle {
website = "https://www.ryandens.com"
vcsUrl = "https://github.com/ryandens/javaagent-gradle-plugin"
tags = listOf("javaagent", "instrumentation", "docker", "jib", "application")
}

Expand All @@ -40,26 +29,12 @@ tasks.named<PluginUnderTestMetadata>("pluginUnderTestMetadata") {
dependencies {
plugin("com.google.cloud.tools:jib-gradle-plugin-extension-api:0.4.0")
plugin("gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:3.2.0")
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
testImplementation("org.apache.commons:commons-compress:1.21")
}

tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.allWarningsAsErrors = true
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

gradlePlugin {
plugins {
create("javaagentApplicationPlugin") {
Expand Down Expand Up @@ -94,21 +69,3 @@ gradlePlugin {
}
}
}

// Add a source set for the functional test suite
val functionalTestSourceSet = sourceSets.create("functionalTest") {
}

gradlePlugin.testSourceSets(functionalTestSourceSet)
configurations["functionalTestImplementation"].extendsFrom(configurations["testImplementation"])

// Add a task to run the functional tests
val functionalTest by tasks.registering(Test::class) {
testClassesDirs = functionalTestSourceSet.output.classesDirs
classpath = functionalTestSourceSet.runtimeClasspath
}

tasks.check {
// Run the functional tests as part of `check`
dependsOn(functionalTest)
}

0 comments on commit 7f0925e

Please sign in to comment.