Skip to content

Commit 3aca00c

Browse files
committed
Make Gradle plugin portal publishing optional (support non plugin projects)
1 parent 57b819e commit 3aca00c

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package nebula.plugin.plugin
22

33
import nebula.test.IntegrationSpec
4-
import spock.util.Exceptions
54

65
class NebulaPluginPluginIntegrationSpec extends IntegrationSpec {
76
def 'plugin applies'() {
@@ -16,15 +15,12 @@ class NebulaPluginPluginIntegrationSpec extends IntegrationSpec {
1615
runTasksSuccessfully('help')
1716
}
1817

19-
def 'plugin does not apply if plugin-publish plugin is not applied'() {
18+
def 'plugin applies when plugin-publish is not applied'() {
2019
buildFile << """
2120
apply plugin: 'nebula.plugin-plugin'
2221
"""
2322

24-
when:
25-
def result = runTasks('help')
26-
27-
then:
28-
Exceptions.getRootCause(result.failure).message == 'The com.gradle.plugin-publish plugin must be applied before this plugin. Expression: project.plugins.findPlugin(id)'
23+
expect:
24+
runTasksSuccessfully('help')
2925
}
3026
}

src/main/groovy/nebula/plugin/plugin/NebulaPluginPlugin.groovy

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class NebulaPluginPlugin implements Plugin<Project> {
2828
'idea',
2929
'jacoco']
3030

31-
static final THIRDPARTY_PLUGIN_IDS = ['com.gradle.plugin-publish', 'com.github.kt3k.coveralls']
31+
static final THIRDPARTY_PLUGIN_IDS = ['com.github.kt3k.coveralls']
3232

3333
static final NEBULA_PLUGIN_IDS = ['nebula.contacts',
3434
'nebula.facet',
@@ -46,7 +46,6 @@ class NebulaPluginPlugin implements Plugin<Project> {
4646

4747
@Override
4848
void apply(Project project) {
49-
assertHasPlugin(project, 'com.gradle.plugin-publish')
5049
project.with {
5150
PLUGIN_IDS.each { plugins.apply(it) }
5251

@@ -83,14 +82,16 @@ class NebulaPluginPlugin implements Plugin<Project> {
8382
jacocoTestReport.executionData += files("$buildDir/jacoco/${task.name}.exec")
8483
}
8584

86-
pluginBundle {
87-
website = "https://github.com/nebula-plugins/${name}"
88-
vcsUrl = "https://github.com/nebula-plugins/${name}.git"
89-
description = project.description
85+
plugins.withId('com.gradle.plugin-publish') {
86+
pluginBundle {
87+
website = "https://github.com/nebula-plugins/${name}"
88+
vcsUrl = "https://github.com/nebula-plugins/${name}.git"
89+
description = project.description
9090

91-
mavenCoordinates {
92-
groupId = group
93-
artifactId = name
91+
mavenCoordinates {
92+
groupId = group
93+
artifactId = name
94+
}
9495
}
9596
}
9697

@@ -104,8 +105,4 @@ class NebulaPluginPlugin implements Plugin<Project> {
104105
}
105106
}
106107
}
107-
108-
static def assertHasPlugin(Project project, String id) {
109-
assert project.plugins.findPlugin(id): "The ${id} plugin must be applied before this plugin"
110-
}
111108
}

0 commit comments

Comments
 (0)