Skip to content

Commit

Permalink
add resolvable convenience method
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Jan 31, 2024
1 parent a76561f commit da4799b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/main/kotlin/org/incendo/cloudbuildlogic/JavadocLinksPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.gradle.kotlin.dsl.registerIfAbsent
import org.incendo.cloudbuildlogic.util.apiElements
import org.incendo.cloudbuildlogic.util.extendsFromFlattened
import org.incendo.cloudbuildlogic.util.javadocElements
import org.incendo.cloudbuildlogic.util.resolvable
import org.incendo.cloudbuildlogic.util.sourcesElements
import javax.inject.Inject

Expand All @@ -38,35 +39,27 @@ abstract class JavadocLinksPlugin : Plugin<Project> {
target.plugins.withId("java-library") {
target.forEachTargetedSourceSet {
val linkDependencies = target.configurations.register(formatName("javadocLinks")) {
extendsFrom(target.configurations.named(apiElementsConfigurationName).get())
isCanBeResolved = true
isCanBeConsumed = false

resolvable()
attributes {
apiElements(objects)
}
extendsFrom(target.configurations.named(apiElementsConfigurationName).get())
}

val javadocConfig = target.configurations.register(linkDependencies.name + "Javadoc") {
isCanBeResolved = true
isCanBeConsumed = false

resolvable()
attributes {
javadocElements(objects)
}

// Gradle doesn't consider transitives when we simply extend the configuration using the above attributes
extendsFromFlattened(linkDependencies, target.dependencies)
}

val sourcesConfig = target.configurations.register(linkDependencies.name + "Sources") {
isCanBeResolved = true
isCanBeConsumed = false

resolvable()
attributes {
sourcesElements(objects)
}

// Gradle doesn't consider transitives when we simply extend the configuration using the above attributes
extendsFromFlattened(linkDependencies, target.dependencies)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ fun Configuration.extendsFromFlattened(
}
}
}

fun Configuration.resolvable() {
isCanBeResolved = true
isCanBeConsumed = false
}

0 comments on commit da4799b

Please sign in to comment.