1- import org.codehaus.groovy.runtime.DefaultGroovyMethods.head
2-
31// :buildSrc
42plugins {
53 alias(buildSrc.plugins.maven.publish)
64 alias(buildSrc.plugins.gradle.plugin)
75 alias(buildSrc.plugins.gradle.publish)
86}
97
10- project.ext.set(" github_handle" , " syslogic" )
11- project.ext.set(" group_id" , " io.syslogic" )
12- project.ext.set(" plugin_display_name" , " AppGallery Connect Publishing Plugin" )
13- project.ext.set(" plugin_description" , " It uploads Android APK/ABB artifacts with AppGallery Connect Publishing API." )
14- project.ext.set(" plugin_identifier" , " agconnect-publishing-gradle-plugin" )
15- project.ext.set(" plugin_class" , " io.syslogic.agconnect.PublishingPlugin" )
16- project.ext.set(" plugin_id" , " io.syslogic.agconnect.publishing" )
17- project.ext.set(" plugin_version" , buildSrc.versions.plugin.version.get())
8+ val pluginId: String by extra(buildSrc.versions.plugin.id.get())
9+ val pluginCls: String by extra(buildSrc.versions.plugin.cls.get())
10+ val pluginGroup: String by extra(buildSrc.versions.plugin.group.get())
11+ val pluginVersion: String by extra(buildSrc.versions.plugin.version.get())
12+ val pluginName: String by extra(buildSrc.versions.plugin.name.get())
13+ val pluginDesc: String by extra(buildSrc.versions.plugin.desc.get())
14+ val pluginIdentifier: String by extra(buildSrc.versions.plugin.identifier.get())
15+ val pluginEmail: String by extra(buildSrc.versions.plugin.email.get())
16+ val pluginDev: String by extra(buildSrc.versions.plugin.dev.get())
17+ val githubHandle: String by extra(buildSrc.versions.github.handle.get())
18+
19+
20+ gradlePlugin {
21+ plugins {
22+ create(" PublishingPlugin" ) {
23+ id = pluginId
24+ implementationClass = pluginCls
25+ displayName = pluginName
26+ description = pluginDesc
27+ }
28+ }
29+ }
1830
1931dependencies {
2032
2133 api(dependencyNotation = gradleApi())
22- // noinspection DependencyNotationArgument
2334 api(dependencyNotation = buildSrc.android.gradle)
2435
25- // noinspection DependencyNotationArgument
2636 implementation(dependencyNotation = buildSrc.annotations)
27- // noinspection DependencyNotationArgument
2837 implementation(dependencyNotation = buildSrc.bundles.http.components)
2938
3039 testImplementation(dependencyNotation = buildSrc.junit)
3140 testImplementation(dependencyNotation = gradleTestKit())
32- // noinspection DependencyNotationArgument
3341 testImplementation(dependencyNotation = buildSrc.annotations)
3442 testImplementation(dependencyNotation = project)
3543}
3644
37- gradlePlugin {
38- plugins {
39- create(" PublishingPlugin" ) {
40- id = " ${project.ext.get(" plugin_id" )} "
41- implementationClass = " ${project.ext.get(" plugin_class" )} "
42- displayName = " ${project.ext.get(" plugin_display_name" )} "
43- description = " ${project.ext.get(" plugin_description" )} "
44- }
45- }
46- }
47-
4845tasks.withType<Test >().configureEach {
4946 useJUnitPlatform()
5047}
5148
5249tasks.withType<Jar >().configureEach {
53- archiveBaseName.set(" ${project.ext.get( " plugin_identifier " )} " )
54- archiveVersion.set(" ${project.ext.get( " plugin_version " )} " )
50+ archiveBaseName.set(pluginIdentifier )
51+ archiveVersion.set(pluginVersion )
5552}
5653
5754// Gradle 9.0 deprecation fix
@@ -61,7 +58,7 @@ val implCls: Configuration by configurations.creating {
6158}
6259
6360val javadocs by tasks.registering(Javadoc ::class ) {
64- title = " ${project.ext.get( " plugin_display_name " )} ${project.ext.get( " plugin_version " )} API"
61+ title = " $pluginName $pluginVersion API"
6562 classpath + = implCls.asFileTree.filter {it.extension == " jar" }
6663 destinationDir = rootProject.file(" build/javadoc" )
6764 source = sourceSets.main.get().allJava
@@ -82,19 +79,20 @@ val sourcesJar by tasks.registering(Jar::class) {
8279 from(sourceSets.main.get().java.srcDirs)
8380}
8481
85- group = " ${project.ext.get(" group_id" )} "
86- version = " ${project.ext.get(" plugin_version" )} "
87-
8882artifacts {
8983 archives(javadocJar)
9084 archives(sourcesJar)
9185}
9286
87+ group = pluginGroup
88+ version = pluginVersion
89+
9390configure<PublishingExtension > {
91+
9492 repositories {
9593 maven {
9694 name = " GitHubPackages"
97- url = uri(" https://maven.pkg.github.com/${project.ext.get( " github_handle " ) } /${project.ext.get( " plugin_identifier " ) } " )
95+ url = uri(" https://maven.pkg.github.com/${githubHandle } /${pluginIdentifier } " )
9896 credentials {
9997 username = System .getenv(" GITHUB_ACTOR" )
10098 password = System .getenv(" GITHUB_TOKEN" )
@@ -103,41 +101,34 @@ configure<PublishingExtension> {
103101 }
104102
105103 publications {
106- register<MavenPublication >(" GPR " ) {
104+ register<MavenPublication >(" Plugin " ) {
107105 from(components.getByName(" java" ))
108- groupId = " ${project.ext.get( " group_id " )} "
109- artifactId = " ${project.ext.get( " plugin_identifier " )} "
110- version = " ${project.ext.get( " plugin_version " )} "
106+ groupId = pluginGroup
107+ artifactId = pluginIdentifier
108+ version = pluginVersion
111109 pom {
112- name = " ${project.ext.get( " plugin_display_name " )} "
113- description = " ${project.ext.get( " plugin_description " )} "
114- url = " https://github.com/${project.ext.get( " github_handle " ) } /${project.ext.get( " plugin_identifier " ) } "
110+ name = pluginName
111+ description = pluginDesc
112+ url = " https://github.com/${githubHandle } /${pluginIdentifier } "
115113 scm {
116- connection = " scm:git:git://github.com/${project.ext.get( " github_handle " ) } /${project.ext.get( " plugin_identifier " ) } .git"
117- developerConnection = " scm:git:ssh://github.com/${project.ext.get( " github_handle " ) } /${project.ext.get( " plugin_identifier " ) } .git"
118- url = " https://github.com/${project.ext.get( " github_handle " ) } /${project.ext.get( " plugin_identifier " ) } /"
114+ connection = " scm:git:git://github.com/${githubHandle } /${pluginIdentifier } .git"
115+ developerConnection = " scm:git:ssh://github.com/${githubHandle } /${pluginIdentifier } .git"
116+ url = " https://github.com/${githubHandle } /${pluginIdentifier } /"
119117 }
120- }
121- }
122-
123- register<MavenPublication >(" JitPack" ) {
124- from(components.getByName(" java" ))
125- groupId = " ${project.ext.get(" group_id" )} "
126- artifactId = " ${project.ext.get(" plugin_identifier" )} "
127- version = " ${project.ext.get(" plugin_version" )} "
128- pom {
129- name = " ${project.ext.get(" plugin_display_name" )} "
130- description = " ${project.ext.get(" plugin_description" )} "
131- url = " https://github.com/${project.ext.get(" github_handle" )} /${project.ext.get(" plugin_identifier" )} "
132- scm {
133- connection = " scm:git:git://github.com/${project.ext.get(" github_handle" )} /${project.ext.get(" plugin_identifier" )} .git"
134- developerConnection = " scm:git:ssh://github.com/${project.ext.get(" github_handle" )} /${project.ext.get(" plugin_identifier" )} .git"
135- url = " https://github.com/${project.ext.get(" github_handle" )} /${project.ext.get(" plugin_identifier" )} /"
118+ developers {
119+ developer {
120+ name = pluginDev
121+ email = pluginEmail
122+ id = githubHandle
123+ }
124+ }
125+ licenses {
126+ license {
127+ name = " MIT License"
128+ url = " http://www.opensource.org/licenses/mit-license.php"
129+ }
136130 }
137131 }
138132 }
139133 }
140134}
141-
142- // tasks.withType<MavenPublication>().forEach { pub: MavenPublication ->
143- // }
0 commit comments