Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

How to apply plugins with modularity? #448

Closed
jaredsburrows opened this issue Jul 31, 2017 · 3 comments
Closed

How to apply plugins with modularity? #448

jaredsburrows opened this issue Jul 31, 2017 · 3 comments

Comments

@jaredsburrows
Copy link
Contributor

I have seen the modularity example here: https://github.com/gradle/kotlin-dsl/tree/master/samples/modularity.

With the current Groovy DSL, you can apply plugins in other *gradle files. For instance, I can apply this gradle file: https://github.com/jaredsburrows/android-gif-example/blob/master/gradle/scan.gradle in the main build.gradle here: https://github.com/jaredsburrows/android-gif-example/blob/master/build.gradle.kts#L34.

If I convert scan.gradle to Kotlin DSL, it no longer works and gives me errors.

@bamboo
Copy link
Member

bamboo commented Aug 1, 2017

Using extensions from script plugins is not yet supported. See #432.

@bamboo bamboo closed this as completed Aug 1, 2017
@magJ
Copy link

magJ commented May 31, 2018

As a workaround until this is fixed properly, you can apply the plugin dynamically.
IE rather than

plugins {
    `maven-publish`
}

publishing {
    repositories {  }
}

You can do:

apply {
    plugin("org.gradle.maven-publish")
}
extensions["publishing"].closureOf<PublishingExtension> {
    repositories {  }
}

Not ideal, but seems to work. Keen to hear any better solutions.

@eskatos
Copy link
Member

eskatos commented May 31, 2018

Here's a nicer workaround, basically doing the same with less code:

apply(plugin = "maven-publish")
configure<PublishingExtension> {
    repositories { ... }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants