Configure publishing via settings DSL instead of gradle properties#33
Configure publishing via settings DSL instead of gradle properties#33joshfriend wants to merge 1 commit intomainfrom
Conversation
4acf3af to
c682fa6
Compare
| * enabled.set(true) | ||
| * repo { | ||
| * url.set("https://repo.example.com/maven") | ||
| * username.set("myuser") | ||
| * password.set("mypassword") |
There was a problem hiding this comment.
Not a big deal, but Kotlin DSL magic lets us use = now instead of set(...).
Although, that said, I usually prefer for my DSLs to only expose functions and not the properties directly. I think it's more maintainable in the end.
| * Sets the repository username and disallows further changes. Convenience method for Groovy | ||
| * DSL. |
There was a problem hiding this comment.
I mean, I would consider just exposing this for both DSLs.
| private fun Project.configureSandbagPom(pom: MavenPom) { | ||
| private fun Project.configureArtifactPom(pom: MavenPom) { |
There was a problem hiding this comment.
This is a better naming convention.
| private lateinit var extension: ArtifactSwapExtension | ||
|
|
||
| override fun apply(target: Settings) = target.run { | ||
| extension = extensions.create("artifactSwap", ArtifactSwapExtension::class.java) |
There was a problem hiding this comment.
I usually like to embed this in the extension class as a factory function.
| gradle.settingsEvaluated { | ||
| logger.lifecycle("publish enabled ${extension.publishing.enabled.get()}") | ||
| if (extension.publishing.enabled.get()) { |
There was a problem hiding this comment.
Why is it important to evaluate that property here? (I'm just always suspicious of things that "look like" afterEvaluate. Is this preferable to checking the final value of enabled in each project context?
There was a problem hiding this comment.
the values from extensions are never available in the initial plugin application, you can only read them in afterSettings (or afterEvaluate for plugins)
|
|
||
| val Project.sandbagHashFile: File | ||
| get() = File(rootDir, providers.gradleProperty(SANDBAG_HASH_FILE).get()) | ||
| val Project.artifactHashFile: File |
There was a problem hiding this comment.
Is there a reason we're using java.io instead of the Gradle API (like RegularFile)?
There was a problem hiding this comment.
thats the type that using file() in build.gradle gave me.
c682fa6 to
ae741a5
Compare

No description provided.