-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
241 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
build-logic/src/main/kotlin/com/squareup/anvil/KtlintConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.squareup.anvil | ||
|
||
import com.rickbusarow.kgx.libsCatalog | ||
import com.rickbusarow.kgx.version | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.jlleitschuh.gradle.ktlint.KtlintExtension | ||
import org.jlleitschuh.gradle.ktlint.KtlintPlugin | ||
|
||
open class KtlintConventionPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
target.plugins.apply(KtlintPlugin::class.java) | ||
|
||
target.plugins.apply(org.jlleitschuh.gradle.ktlint.KtlintPlugin::class.java) | ||
|
||
target.extensions.configure(KtlintExtension::class.java) { ktlint -> | ||
ktlint.version.set(target.libsCatalog.version("ktlint")) | ||
ktlint.verbose.set(true) | ||
} | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
build-logic/src/main/kotlin/com/squareup/anvil/PublishConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.squareup.anvil | ||
|
||
import com.vanniktech.maven.publish.JavadocJar | ||
import com.vanniktech.maven.publish.KotlinJvm | ||
import com.vanniktech.maven.publish.MavenPublishBaseExtension | ||
import com.vanniktech.maven.publish.Platform | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.publish.PublishingExtension | ||
import org.gradle.api.publish.maven.MavenPublication | ||
import org.gradle.api.publish.tasks.GenerateModuleMetadata | ||
import org.gradle.api.tasks.bundling.Jar | ||
import javax.inject.Inject | ||
|
||
open class PublishConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
|
||
target.plugins.apply("com.vanniktech.maven.publish.base") | ||
target.plugins.apply("org.jetbrains.dokka") | ||
|
||
target.extensions.create("publish", PublishExtension::class.java) | ||
|
||
val mavenPublishing = target.extensions | ||
.getByType(MavenPublishBaseExtension::class.java) | ||
|
||
val pluginPublishId = "com.gradle.plugin-publish" | ||
|
||
@Suppress("UnstableApiUsage") | ||
mavenPublishing.pomFromGradleProperties() | ||
mavenPublishing.signAllPublications() | ||
|
||
target.plugins.withId("org.jetbrains.kotlin.jvm") { | ||
|
||
when { | ||
target.plugins.hasPlugin(pluginPublishId) -> { | ||
// Gradle's 'plugin-publish' plugin creates its own publication. We only apply this plugin | ||
// in order to get all the automated POM configuration. | ||
} | ||
|
||
else -> { | ||
configurePublication( | ||
target, | ||
mavenPublishing, | ||
KotlinJvm(javadocJar = JavadocJar.Dokka("dokkaHtml"), sourcesJar = true) | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Suppress("UnstableApiUsage") | ||
private fun configurePublication( | ||
target: Project, | ||
mavenPublishing: MavenPublishBaseExtension, | ||
platform: Platform | ||
) { | ||
mavenPublishing.configure(platform) | ||
|
||
target.tasks.withType(GenerateModuleMetadata::class.java).configureEach { | ||
it.mustRunAfter(target.tasks.withType(Jar::class.java)) | ||
it.mustRunAfter("dokkaJavadocJar") | ||
it.mustRunAfter("kotlinSourcesJar") | ||
} | ||
} | ||
} | ||
|
||
open class PublishExtension @Inject constructor( | ||
private val target: Project, | ||
) { | ||
fun configurePom(args: Map<String, Any>) { | ||
|
||
val artifactId = args.getValue("artifactId") as String | ||
val pomName = args.getValue("pomName") as String | ||
val pomDescription = args.getValue("pomDescription") as String | ||
|
||
target.extensions | ||
.getByType(PublishingExtension::class.java) | ||
.publications.withType(MavenPublication::class.java) | ||
.matching { !it.name.endsWith("PluginMarkerMaven") } | ||
.configureEach { publication -> | ||
|
||
// Gradle plugin publications have their own artifactID convention, | ||
// and that's handled automatically. | ||
if (!publication.name.endsWith("PluginMarkerMaven")) { | ||
publication.artifactId = artifactId | ||
} | ||
|
||
publication.pom { | ||
it.name.set(pomName) | ||
it.description.set(pomDescription) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.