Skip to content

Commit

Permalink
Extract a convention plugin for configuring adapter projects
Browse files Browse the repository at this point in the history
  • Loading branch information
pshevche committed Mar 14, 2024
1 parent e6c3eb4 commit 5b909ed
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 42 deletions.
7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repositories {
gradlePluginPortal()
}

plugins {
`kotlin-dsl`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package develocity.adapters

import org.gradle.api.Project
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.SourceSetOutput
import org.gradle.kotlin.dsl.the

fun Project.sourceSetOutput(name: String): SourceSetOutput = the<SourceSetContainer>().getByName(name).output
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import develocity.adapters.sourceSetOutput

plugins {
java
}

repositories {
mavenCentral()
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}

sourceSets {
create("compatibilityApi")
create("enterpriseCompatibility")
create("develocityCompatibility")
}

tasks.jar {
from(sourceSetOutput("compatibilityApi"))
from(sourceSetOutput("enterpriseCompatibility"))
from(sourceSetOutput("develocityCompatibility"))
}
29 changes: 5 additions & 24 deletions develocity-gradle-plugin-adapters/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import develocity.adapters.sourceSetOutput

plugins {
java
id("develocity.adapters-library")
}

repositories {
Expand All @@ -12,35 +14,14 @@ repositories {
}
}

sourceSets {
create("compatibilityApi")
create("enterpriseCompatibility")
create("develocityCompatibility")
}

fun sourceSet(name: String): SourceSetOutput = sourceSets[name].output

dependencies {
"compatibilityApiCompileOnly"(gradleApi())

"enterpriseCompatibilityCompileOnly"(gradleApi())
"enterpriseCompatibilityCompileOnly"(libs.gradle.enterprise.plugin)
"enterpriseCompatibilityImplementation"(sourceSet("compatibilityApi"))
"enterpriseCompatibilityImplementation"(sourceSetOutput("compatibilityApi"))

"develocityCompatibilityCompileOnly"(gradleApi())
"develocityCompatibilityCompileOnly"(libs.develocity.plugin)
"develocityCompatibilityImplementation"(sourceSet("compatibilityApi"))
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
"develocityCompatibilityImplementation"(sourceSetOutput("compatibilityApi"))
}

tasks.jar {
from(sourceSet("compatibilityApi"))
from(sourceSet("enterpriseCompatibility"))
from(sourceSet("develocityCompatibility"))
}

23 changes: 5 additions & 18 deletions develocity-maven-plugin-adapters/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import develocity.adapters.sourceSetOutput

plugins {
java
id("develocity.adapters-library")
}

repositories {
mavenCentral()
maven {
url = uri("https://repo.grdev.net/artifactory/public")
content {
Expand All @@ -12,28 +13,14 @@ repositories {
}
}

sourceSets {
create("compatibilityApi")
create("enterpriseCompatibility")
create("develocityCompatibility")
}

fun sourceSet(name: String): SourceSetOutput = sourceSets[name].output

dependencies {
"compatibilityApiCompileOnly"(libs.maven.core)

"enterpriseCompatibilityCompileOnly"(libs.maven.core)
"enterpriseCompatibilityCompileOnly"(libs.gradle.enterprise.extension)
"enterpriseCompatibilityImplementation"(sourceSet("compatibilityApi"))
"enterpriseCompatibilityImplementation"(sourceSetOutput("compatibilityApi"))

"develocityCompatibilityCompileOnly"(libs.maven.core)
"develocityCompatibilityCompileOnly"(libs.develocity.extension)
"develocityCompatibilityImplementation"(sourceSet("compatibilityApi"))
}

tasks.jar {
from(sourceSet("compatibilityApi"))
from(sourceSet("enterpriseCompatibility"))
from(sourceSet("develocityCompatibility"))
"develocityCompatibilityImplementation"(sourceSetOutput("compatibilityApi"))
}

0 comments on commit 5b909ed

Please sign in to comment.