Skip to content

Commit

Permalink
Make Gradle plugin portal publishing optional (support non plugin pro…
Browse files Browse the repository at this point in the history
…jects)
  • Loading branch information
DanielThomas committed May 30, 2016
1 parent 57b819e commit 3aca00c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package nebula.plugin.plugin

import nebula.test.IntegrationSpec
import spock.util.Exceptions

class NebulaPluginPluginIntegrationSpec extends IntegrationSpec {
def 'plugin applies'() {
Expand All @@ -16,15 +15,12 @@ class NebulaPluginPluginIntegrationSpec extends IntegrationSpec {
runTasksSuccessfully('help')
}

def 'plugin does not apply if plugin-publish plugin is not applied'() {
def 'plugin applies when plugin-publish is not applied'() {
buildFile << """
apply plugin: 'nebula.plugin-plugin'
"""

when:
def result = runTasks('help')

then:
Exceptions.getRootCause(result.failure).message == 'The com.gradle.plugin-publish plugin must be applied before this plugin. Expression: project.plugins.findPlugin(id)'
expect:
runTasksSuccessfully('help')
}
}
23 changes: 10 additions & 13 deletions src/main/groovy/nebula/plugin/plugin/NebulaPluginPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class NebulaPluginPlugin implements Plugin<Project> {
'idea',
'jacoco']

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

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

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

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

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

mavenCoordinates {
groupId = group
artifactId = name
mavenCoordinates {
groupId = group
artifactId = name
}
}
}

Expand All @@ -104,8 +105,4 @@ class NebulaPluginPlugin implements Plugin<Project> {
}
}
}

static def assertHasPlugin(Project project, String id) {
assert project.plugins.findPlugin(id): "The ${id} plugin must be applied before this plugin"
}
}

0 comments on commit 3aca00c

Please sign in to comment.