Wouldn't it be possible for the API plugin to check whether or not the base
plugin had already been applied?
Op 12 apr. 2012 01:18 schreef "Eric Berry" <[email protected]> het volgende:

> Hi Adam, and Peter,
>    Thank you both for the quick response.
>
> Adam, guess we'll have to stick with the "apply from" scripts that have
> the extra code to check to see if the plugin is installed.
>
> Peter, we're using what I think you'd call binary plugins at Chegg. We
> have an artifactory repository that hosts the plugin's artifacts, which our
> developers use by way of a a script:
>
> [code src="
> http://internal.host/gradle-plugins/installation/chegg-corp.groovy";]
> buildscript {
>  repositories {
> mavenRepo url: "http://internal.host/artifactory/repo";
>  }
> dependencies {
>  classpath "com.chegg.corp.gradle:chegg-plugin:12.2"
> }
> }
> // Check to make sure CheggCorpPlugin isn't already added.
> boolean hasCorp = project.plugins.find { plugin ->
>  "${plugin.getClass()}" == "${com.chegg.corp.CheggCorpPlugin}"
> }
> if (!hasCorp) {
> project.apply(plugin: com.chegg.corp.CheggCorpPlugin)
> }
> [/code]
>
> This is fine except for the extra junk at the end where I need to check to
> see if the plugin is already installed.
>
> I did some testing and I found that if you use the plugin ID's (eg. apply
> plugin: "chegg-corp") gradle gracefully handles the plugin being applied
> multiple times, but because of this bug:
> http://issues.gradle.org/browse/GRADLE-1517
>
> We are forced to use the plugin's class, which doesn't seem to work the
> same way.
>
> The problem here is that we have one plugin called "chegg-corp", and
> another "chegg-corp-api" which also applies the "chegg-corp" plugin.  Some
> of our projects use the subprojects closure to apply the "chegg-corp"
> plugin, and then have an "api" module that applies the "chegg-corp-api"
> plugin. Gradle complains about the "chegg-corp" plugin already being
> installed without the check. So I have to do the check in multiple places -
> once in the "apply from" scripts, and anywhere else that one plugin applies
> another.
>
> If #1517 could be fixed, that would reduce a lot of boiler plate for our
> plugins and our "apply from" scripts. I've already voted for the bug, but
> would really appreciate it if that would could be fixed for 1.0, or at
> least make it so applying the plugin via class works the same way as
> applying it via ID.
>
> --
> Learn from the past. Live in the present. Plan for the future.
> Blog: http://eric-berry.blogspot.com
> jEdit <http://www.jedit.org> - Programmer's Text Editor
> Bazaar <http://bazaar.canonical.com> - Version Control for Humans
>

Reply via email to