forked from square/dagger
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add maven publish plugin to Gradle projects.
Only adds the plugin and POM configuration enabling publishing to local repository, not yet configured for actual world publishing. RELNOTES=N/A PiperOrigin-RevId: 713019870
- Loading branch information
1 parent
9daa0ae
commit 8b4f9b6
Showing
7 changed files
with
105 additions
and
8 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
73 changes: 73 additions & 0 deletions
73
buildSrc/src/main/kotlin/dagger/gradle/build/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,73 @@ | ||
/* | ||
* Copyright (C) 2025 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dagger.gradle.build | ||
|
||
import com.vanniktech.maven.publish.MavenPublishBaseExtension | ||
import com.vanniktech.maven.publish.SonatypeHost | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
||
class PublishConventionPlugin : Plugin<Project> { | ||
override fun apply(project: Project) { | ||
project.pluginManager.apply(project.getPluginIdByName("publish")) | ||
|
||
project.plugins.withId(project.getPluginIdByName("publish")) { | ||
val publishExtension = project.extensions.getByName("mavenPublishing") as MavenPublishBaseExtension | ||
publishExtension.apply { | ||
coordinates( | ||
groupId = "com.google.dagger", | ||
artifactId = project.name, | ||
version = project.findProperty("PUBLISH_VERSION").toString() | ||
) | ||
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) | ||
pom { | ||
name.set(project.name.asPomName()) | ||
description.set("A fast dependency injector for Android and Java.") | ||
url.set("https://github.com/google/dagger") | ||
scm { | ||
url.set("https://github.com/google/dagger/") | ||
connection.set("scm:git:git://github.com/google/dagger.git") | ||
} | ||
issueManagement { | ||
system.set("GitHub Issues") | ||
url.set("https://github.com/google/dagger/issues") | ||
} | ||
licenses { | ||
license { | ||
name.set("The Apache Software License, Version 2.0") | ||
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") | ||
} | ||
} | ||
organization { | ||
name.set("Google, Inc.") | ||
url.set("https://www.google.com") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Converts the Gradle project name to a more appropriate name for the POM file. | ||
* | ||
* For example: 'dagger-compiler' to 'Dagger Compiler' | ||
*/ | ||
private fun String.asPomName(): String { | ||
val parts = split("-").map { first().uppercaseChar() + drop(1) } | ||
return parts.joinToString(separator = " ") | ||
} | ||
} |
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 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