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

Script plugins with external dependencies defined in a buildscript block #180

Closed
bamboo opened this issue Nov 18, 2016 · 8 comments
Closed

Comments

@bamboo
Copy link
Member

bamboo commented Nov 18, 2016

For *.gradle.kts files including Settings script plugins (*.settings.gradle.kts).

@eskatos
Copy link
Member

eskatos commented Apr 25, 2018

This is now done for scripts applied to project and settings. Remain scripts applied from init scripts. Today you would have to use initscript {} in those applied scripts but it should be buildscript {} instead. Only the top level init scripts must use initscript {}.

@bamboo
Copy link
Member Author

bamboo commented May 4, 2018

I'm afraid we'll need to deviate from Groovy here in order to provide good IDE support.

The *.init.gradle.kts pattern implies an init script for the IDE and those scripts expect the classpath to be defined in a initscript.

@bamboo
Copy link
Member Author

bamboo commented May 11, 2018

Closing as delivered for Project and Settings script plugins. For init script support see #870.

@bamboo bamboo closed this as completed May 11, 2018
bamboo added a commit that referenced this issue May 14, 2018
Now that #180 has been implemented.

IDE support to come as part of #110.
@thc202
Copy link

thc202 commented May 29, 2018

@bamboo or @eskatos should this change also allow applied scripts to apply plugins? (Same set up as described in #814. I didn't find any open issue with this use case, some were closed as duplicate other as superseded, might have missed it though. #425 would address it but not exactly the same and this use case is supported with Groovy DSL).

I'm getting the following error:

FAILURE: Build failed with an exception.

* Where:
Script 'publishing-portal.gradle.kts' line: 12

* What went wrong:
Plugin with id 'com.gradle.plugin-publish' not found.

when attempting to apply a plugin from an applied script, e.g.:
build.gradle.kts

apply(from = "publishing-portal.gradle.kts")

publishing-portal.gradle.kts

buildscript {
    repositories {
        maven {
            url = uri("https://plugins.gradle.org/m2/")
        }
    }
    dependencies {
        classpath ("com.gradle.publish:plugin-publish-plugin:0.9.10")
    }
}

apply(plugin = "com.gradle.plugin-publish")

The above works fine if done directly in build.gradle.kts.

Versions:

------------------------------------------------------------
Gradle 4.8-rc-2
------------------------------------------------------------

Build time:   2018-05-24 09:28:21 UTC
Revision:     0b1824635622a85b201776fc1245b6a40f4a5b22

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM:          10.0.1 (Oracle Corporation 10.0.1+10-Ubuntu-3ubuntu1)
OS:           Linux 4.15.0-22-generic amd64

@bamboo
Copy link
Member Author

bamboo commented May 30, 2018

That looks like gradle/gradle#1262

@thc202
Copy link

thc202 commented May 30, 2018

Thanks! It works fine using the type. (I didn't look into Gradle issue tracker because it works fine with Groovy DSL and I was expecting that to just work in Kotlin DSL.)

@bamboo
Copy link
Member Author

bamboo commented May 30, 2018

it works fine with Groovy DSL

Hm, it shouldn't, gradle/gradle#1262 is about the Groovy DSL.

In fact I've just converted your repro scripts to the Groovy DSL and got the exact same error.

@thc202
Copy link

thc202 commented May 30, 2018

Ouch! Messed up the conversion somewhere... Indeed, in the original Groovy script was using the type as well apply plugin: com.gradle.publish.PublishPlugin. Thank you.

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

3 participants