Skip to content

Commit 3293cdd

Browse files
committed
Publish plugins
Publishing is only an additional configuration of the plugins build. Hence it is the same setup for all approaches. You can publish: - To your own repository. Then you only need the id("maven-publish") plugin and configure your repository - To the Gradle Plugin Portal. Then you additionally need the id("com.gradle.plugin-publish") plugin and configure additional metadata that will be shown on the plugin portal website.
1 parent 39baa4d commit 3293cdd

File tree

7 files changed

+77
-0
lines changed

7 files changed

+77
-0
lines changed

clojure/gradle-build-logic/java-plugins/build.gradle.kts

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
plugins {
22
id("java-gradle-plugin")
33
id("dev.clojurephant.clojure") version "0.6.0"
4+
id("maven-publish") // if you never publish the plugin, you may remove this (but it also does not hurt)
5+
id("com.gradle.plugin-publish") version "1.0.0" // if you do not publish to the Gradle Plugin Portal, you may remove this (but it also does not hurt)
46
}
57

68
// clojurephant plugin specifics
@@ -30,3 +32,12 @@ dependencies {
3032
because("Provides the 'com.diffplug.spotless' formatting plugin")
3133
}
3234
}
35+
36+
// if you do not publish, the following is optional
37+
version = "1.0"
38+
publishing.repositories.maven("../../../_gradle-plugins-repository") // own repository to publish to (if needed) - run ':publish' task
39+
pluginBundle { // Plugin Portal Metadata (only needed if you publish to Gradle Plugin Portal) - run ':publishPlugins' task
40+
website = "https://github.com/jjohannes/gradle-plugins-howto"
41+
vcsUrl = "https://github.com/jjohannes/gradle-plugins-howto.git"
42+
tags = listOf("example")
43+
}

groovy-dsl/gradle-build-logic/java-plugins/build.gradle.kts

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
plugins {
22
id("groovy-gradle-plugin")
3+
id("maven-publish") // if you never publish the plugin, you may remove this (but it also does not hurt)
4+
id("com.gradle.plugin-publish") version "1.0.0" // if you do not publish to the Gradle Plugin Portal, you may remove this (but it also does not hurt)
35
}
46

57
group = "software.onepiece.gradle.pluginshowto"
@@ -11,3 +13,12 @@ dependencies {
1113
because("Provides the 'com.diffplug.spotless' formatting plugin")
1214
}
1315
}
16+
17+
// if you do not publish, the following is optional
18+
version = "1.0"
19+
publishing.repositories.maven("../../../_gradle-plugins-repository") // own repository to publish to (if needed) - run ':publish' task
20+
pluginBundle { // Plugin Portal Metadata (only needed if you publish to Gradle Plugin Portal) - run ':publishPlugins' task
21+
website = "https://github.com/jjohannes/gradle-plugins-howto"
22+
vcsUrl = "https://github.com/jjohannes/gradle-plugins-howto.git"
23+
tags = listOf("example")
24+
}

groovy/gradle-build-logic/java-plugins/build.gradle.kts

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
plugins {
22
id("java-gradle-plugin")
33
id("groovy")
4+
id("maven-publish") // if you never publish the plugin, you may remove this (but it also does not hurt)
5+
id("com.gradle.plugin-publish") version "1.0.0" // if you do not publish to the Gradle Plugin Portal, you may remove this (but it also does not hurt)
46
}
57

68
group = "software.onepiece.gradle.pluginshowto"
@@ -26,3 +28,12 @@ dependencies {
2628
because("Provides the 'com.diffplug.spotless' formatting plugin")
2729
}
2830
}
31+
32+
// if you do not publish, the following is optional
33+
version = "1.0"
34+
publishing.repositories.maven("../../../_gradle-plugins-repository") // own repository to publish to (if needed) - run ':publish' task
35+
pluginBundle { // Plugin Portal Metadata (only needed if you publish to Gradle Plugin Portal) - run ':publishPlugins' task
36+
website = "https://github.com/jjohannes/gradle-plugins-howto"
37+
vcsUrl = "https://github.com/jjohannes/gradle-plugins-howto.git"
38+
tags = listOf("example")
39+
}

java/gradle-build-logic/java-plugins/build.gradle.kts

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
plugins {
22
id("java-gradle-plugin")
3+
id("maven-publish") // if you never publish the plugin, you may remove this (but it also does not hurt)
4+
id("com.gradle.plugin-publish") version "1.0.0" // if you do not publish to the Gradle Plugin Portal, you may remove this (but it also does not hurt)
35
}
46

57
group = "software.onepiece.gradle.pluginshowto"
@@ -25,3 +27,12 @@ dependencies {
2527
because("Provides the 'com.diffplug.spotless' formatting plugin")
2628
}
2729
}
30+
31+
// if you do not publish, the following is optional
32+
version = "1.0"
33+
publishing.repositories.maven("../../../_gradle-plugins-repository") // own repository to publish to (if needed) - run ':publish' task
34+
pluginBundle { // Plugin Portal Metadata (only needed if you publish to Gradle Plugin Portal) - run ':publishPlugins' task
35+
website = "https://github.com/jjohannes/gradle-plugins-howto"
36+
vcsUrl = "https://github.com/jjohannes/gradle-plugins-howto.git"
37+
tags = listOf("example")
38+
}

kotlin-dsl/gradle-build-logic/java-plugins/build.gradle.kts

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
plugins {
22
`kotlin-dsl`
3+
id("maven-publish") // if you never publish the plugin, you may remove this (but it also does not hurt)
4+
id("com.gradle.plugin-publish") version "1.0.0" // if you do not publish to the Gradle Plugin Portal, you may remove this (but it also does not hurt)
35
}
46

57
group = "software.onepiece.gradle.pluginshowto"
@@ -11,3 +13,12 @@ dependencies {
1113
because("Provides the 'com.diffplug.spotless' formatting plugin")
1214
}
1315
}
16+
17+
// if you do not publish, the following is optional
18+
version = "1.0"
19+
publishing.repositories.maven("../../../_gradle-plugins-repository") // own repository to publish to (if needed) - run ':publish' task
20+
pluginBundle { // Plugin Portal Metadata (only needed if you publish to Gradle Plugin Portal) - run ':publishPlugins' task
21+
website = "https://github.com/jjohannes/gradle-plugins-howto"
22+
vcsUrl = "https://github.com/jjohannes/gradle-plugins-howto.git"
23+
tags = listOf("example")
24+
}

kotlin/gradle-build-logic/java-plugins/build.gradle.kts

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
plugins {
22
id("java-gradle-plugin")
33
id("org.jetbrains.kotlin.jvm") version "1.5.21" // caveat: version should match version embedded in Gradle version you are using
4+
id("maven-publish") // if you never publish the plugin, you may remove this (but it also does not hurt)
5+
id("com.gradle.plugin-publish") version "1.0.0" // if you do not publish to the Gradle Plugin Portal, you may remove this (but it also does not hurt)
46
}
57

68
group = "software.onepiece.gradle.pluginshowto"
@@ -26,3 +28,12 @@ dependencies {
2628
because("Provides the 'com.diffplug.spotless' formatting plugin")
2729
}
2830
}
31+
32+
// if you do not publish, the following is optional
33+
version = "1.0"
34+
publishing.repositories.maven("../../../_gradle-plugins-repository") // own repository to publish to (if needed) - run ':publish' task
35+
pluginBundle { // Plugin Portal Metadata (only needed if you publish to Gradle Plugin Portal) - run ':publishPlugins' task
36+
website = "https://github.com/jjohannes/gradle-plugins-howto"
37+
vcsUrl = "https://github.com/jjohannes/gradle-plugins-howto.git"
38+
tags = listOf("example")
39+
}

scala/gradle-build-logic/java-plugins/build.gradle.kts

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
plugins {
22
id("java-gradle-plugin")
33
id("scala")
4+
id("maven-publish") // if you never publish the plugin, you may remove this (but it also does not hurt)
5+
id("com.gradle.plugin-publish") version "1.0.0" // if you do not publish to the Gradle Plugin Portal, you may remove this (but it also does not hurt)
46
}
57

68
dependencies { implementation("org.scala-lang:scala-library:2.13.6") }
@@ -28,3 +30,12 @@ dependencies {
2830
because("Provides the 'com.diffplug.spotless' formatting plugin")
2931
}
3032
}
33+
34+
// if you do not publish, the following is optional
35+
version = "1.0"
36+
publishing.repositories.maven("../../../_gradle-plugins-repository") // own repository to publish to (if needed) - run ':publish' task
37+
pluginBundle { // Plugin Portal Metadata (only needed if you publish to Gradle Plugin Portal) - run ':publishPlugins' task
38+
website = "https://github.com/jjohannes/gradle-plugins-howto"
39+
vcsUrl = "https://github.com/jjohannes/gradle-plugins-howto.git"
40+
tags = listOf("example")
41+
}

0 commit comments

Comments
 (0)