Gradle composite build with custom gradle plugin fails in IntelliJ: “Could not find method api() for...
I have a Gradle composite build project which contains a custom Gradle plugin. This project builds fine when using Gradle CLI, but IntelliJ fails.
I tried a few different variations on the plugin version within the resolutionStrategy
block: org.test:test-plugin:0.0.1
and test-plugin:test-plugin.gradle.plugin:0.0.1
as described here: https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_markers - both of those work from the CLI; changing to invalid values ("blah:blah") causes a failure.
I've made a sample Github project that contains the code to reproduce, here: https://github.com/mwmitchell/intellij-gradle-plugin-composite-build-bug along with instructions to reproduce and a workaround. The workaround is something that's not really feasible for me, as it requires repeating configuration code (dependencies, plugins etc.) and I have many, many projects that require the same/common configuration.
I would expect IntelliJ to load the project successfully, just like the CLI does. It seems like IntelliJ is loading the sub-project (:project-1:library-a
) before the parent (:project-1
), such that the java-library
is not actually applied to the sub-project when it's evaluated.
gradle intellij-idea intellij-plugin
add a comment |
I have a Gradle composite build project which contains a custom Gradle plugin. This project builds fine when using Gradle CLI, but IntelliJ fails.
I tried a few different variations on the plugin version within the resolutionStrategy
block: org.test:test-plugin:0.0.1
and test-plugin:test-plugin.gradle.plugin:0.0.1
as described here: https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_markers - both of those work from the CLI; changing to invalid values ("blah:blah") causes a failure.
I've made a sample Github project that contains the code to reproduce, here: https://github.com/mwmitchell/intellij-gradle-plugin-composite-build-bug along with instructions to reproduce and a workaround. The workaround is something that's not really feasible for me, as it requires repeating configuration code (dependencies, plugins etc.) and I have many, many projects that require the same/common configuration.
I would expect IntelliJ to load the project successfully, just like the CLI does. It seems like IntelliJ is loading the sub-project (:project-1:library-a
) before the parent (:project-1
), such that the java-library
is not actually applied to the sub-project when it's evaluated.
gradle intellij-idea intellij-plugin
Forgot to mention that I've tried Gradle 4.10.2 and Gralde 4.10.3, and my IntelliJ version is:IntelliJ IDEA 2018.3.2 (Community Edition) Build #IC-183.4886.37, built on December 17, 2018 JRE: 1.8.0_152-release-1343-b26 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.13.6
– mmitchell
Dec 30 '18 at 4:58
I've updated the README.md in the sample project on Github to show how publishing to maven local allows IntelliJ to successfully load the project. Although IntelliJ itself is unable to publishToMavenLocal due to a duplicate root project name.
– mmitchell
Dec 30 '18 at 6:04
It looks like when you build the main project from command line the:project-1:library-a
project is not included into build: only onesettings.gradle
is allowed for the Gradle project (and gradle uses only the root's projectsettings.gradle
file). When I importproject-1
project into IDE it also builds fine for me.
– Andrey
Dec 30 '18 at 7:18
The approach I'm taking is to useincludeBuild
though, which from the Gradle examples/docs show that projects loaded withincludeBuild
are treated separately. Here's the example I originally followed: github.com/gradle/gradle/tree/master/subprojects/docs/src/… -- and then this one as well: github.com/gradle/gradle/tree/master/subprojects/docs/src/…
– mmitchell
Dec 30 '18 at 16:30
add a comment |
I have a Gradle composite build project which contains a custom Gradle plugin. This project builds fine when using Gradle CLI, but IntelliJ fails.
I tried a few different variations on the plugin version within the resolutionStrategy
block: org.test:test-plugin:0.0.1
and test-plugin:test-plugin.gradle.plugin:0.0.1
as described here: https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_markers - both of those work from the CLI; changing to invalid values ("blah:blah") causes a failure.
I've made a sample Github project that contains the code to reproduce, here: https://github.com/mwmitchell/intellij-gradle-plugin-composite-build-bug along with instructions to reproduce and a workaround. The workaround is something that's not really feasible for me, as it requires repeating configuration code (dependencies, plugins etc.) and I have many, many projects that require the same/common configuration.
I would expect IntelliJ to load the project successfully, just like the CLI does. It seems like IntelliJ is loading the sub-project (:project-1:library-a
) before the parent (:project-1
), such that the java-library
is not actually applied to the sub-project when it's evaluated.
gradle intellij-idea intellij-plugin
I have a Gradle composite build project which contains a custom Gradle plugin. This project builds fine when using Gradle CLI, but IntelliJ fails.
I tried a few different variations on the plugin version within the resolutionStrategy
block: org.test:test-plugin:0.0.1
and test-plugin:test-plugin.gradle.plugin:0.0.1
as described here: https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_markers - both of those work from the CLI; changing to invalid values ("blah:blah") causes a failure.
I've made a sample Github project that contains the code to reproduce, here: https://github.com/mwmitchell/intellij-gradle-plugin-composite-build-bug along with instructions to reproduce and a workaround. The workaround is something that's not really feasible for me, as it requires repeating configuration code (dependencies, plugins etc.) and I have many, many projects that require the same/common configuration.
I would expect IntelliJ to load the project successfully, just like the CLI does. It seems like IntelliJ is loading the sub-project (:project-1:library-a
) before the parent (:project-1
), such that the java-library
is not actually applied to the sub-project when it's evaluated.
gradle intellij-idea intellij-plugin
gradle intellij-idea intellij-plugin
asked Dec 30 '18 at 4:46
mmitchellmmitchell
112
112
Forgot to mention that I've tried Gradle 4.10.2 and Gralde 4.10.3, and my IntelliJ version is:IntelliJ IDEA 2018.3.2 (Community Edition) Build #IC-183.4886.37, built on December 17, 2018 JRE: 1.8.0_152-release-1343-b26 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.13.6
– mmitchell
Dec 30 '18 at 4:58
I've updated the README.md in the sample project on Github to show how publishing to maven local allows IntelliJ to successfully load the project. Although IntelliJ itself is unable to publishToMavenLocal due to a duplicate root project name.
– mmitchell
Dec 30 '18 at 6:04
It looks like when you build the main project from command line the:project-1:library-a
project is not included into build: only onesettings.gradle
is allowed for the Gradle project (and gradle uses only the root's projectsettings.gradle
file). When I importproject-1
project into IDE it also builds fine for me.
– Andrey
Dec 30 '18 at 7:18
The approach I'm taking is to useincludeBuild
though, which from the Gradle examples/docs show that projects loaded withincludeBuild
are treated separately. Here's the example I originally followed: github.com/gradle/gradle/tree/master/subprojects/docs/src/… -- and then this one as well: github.com/gradle/gradle/tree/master/subprojects/docs/src/…
– mmitchell
Dec 30 '18 at 16:30
add a comment |
Forgot to mention that I've tried Gradle 4.10.2 and Gralde 4.10.3, and my IntelliJ version is:IntelliJ IDEA 2018.3.2 (Community Edition) Build #IC-183.4886.37, built on December 17, 2018 JRE: 1.8.0_152-release-1343-b26 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.13.6
– mmitchell
Dec 30 '18 at 4:58
I've updated the README.md in the sample project on Github to show how publishing to maven local allows IntelliJ to successfully load the project. Although IntelliJ itself is unable to publishToMavenLocal due to a duplicate root project name.
– mmitchell
Dec 30 '18 at 6:04
It looks like when you build the main project from command line the:project-1:library-a
project is not included into build: only onesettings.gradle
is allowed for the Gradle project (and gradle uses only the root's projectsettings.gradle
file). When I importproject-1
project into IDE it also builds fine for me.
– Andrey
Dec 30 '18 at 7:18
The approach I'm taking is to useincludeBuild
though, which from the Gradle examples/docs show that projects loaded withincludeBuild
are treated separately. Here's the example I originally followed: github.com/gradle/gradle/tree/master/subprojects/docs/src/… -- and then this one as well: github.com/gradle/gradle/tree/master/subprojects/docs/src/…
– mmitchell
Dec 30 '18 at 16:30
Forgot to mention that I've tried Gradle 4.10.2 and Gralde 4.10.3, and my IntelliJ version is:
IntelliJ IDEA 2018.3.2 (Community Edition) Build #IC-183.4886.37, built on December 17, 2018 JRE: 1.8.0_152-release-1343-b26 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.13.6
– mmitchell
Dec 30 '18 at 4:58
Forgot to mention that I've tried Gradle 4.10.2 and Gralde 4.10.3, and my IntelliJ version is:
IntelliJ IDEA 2018.3.2 (Community Edition) Build #IC-183.4886.37, built on December 17, 2018 JRE: 1.8.0_152-release-1343-b26 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.13.6
– mmitchell
Dec 30 '18 at 4:58
I've updated the README.md in the sample project on Github to show how publishing to maven local allows IntelliJ to successfully load the project. Although IntelliJ itself is unable to publishToMavenLocal due to a duplicate root project name.
– mmitchell
Dec 30 '18 at 6:04
I've updated the README.md in the sample project on Github to show how publishing to maven local allows IntelliJ to successfully load the project. Although IntelliJ itself is unable to publishToMavenLocal due to a duplicate root project name.
– mmitchell
Dec 30 '18 at 6:04
It looks like when you build the main project from command line the
:project-1:library-a
project is not included into build: only one settings.gradle
is allowed for the Gradle project (and gradle uses only the root's project settings.gradle
file). When I import project-1
project into IDE it also builds fine for me.– Andrey
Dec 30 '18 at 7:18
It looks like when you build the main project from command line the
:project-1:library-a
project is not included into build: only one settings.gradle
is allowed for the Gradle project (and gradle uses only the root's project settings.gradle
file). When I import project-1
project into IDE it also builds fine for me.– Andrey
Dec 30 '18 at 7:18
The approach I'm taking is to use
includeBuild
though, which from the Gradle examples/docs show that projects loaded with includeBuild
are treated separately. Here's the example I originally followed: github.com/gradle/gradle/tree/master/subprojects/docs/src/… -- and then this one as well: github.com/gradle/gradle/tree/master/subprojects/docs/src/…– mmitchell
Dec 30 '18 at 16:30
The approach I'm taking is to use
includeBuild
though, which from the Gradle examples/docs show that projects loaded with includeBuild
are treated separately. Here's the example I originally followed: github.com/gradle/gradle/tree/master/subprojects/docs/src/… -- and then this one as well: github.com/gradle/gradle/tree/master/subprojects/docs/src/…– mmitchell
Dec 30 '18 at 16:30
add a comment |
1 Answer
1
active
oldest
votes
Gradle projects can have only one settings.gradle
. You can include subproject "library-a" with include 'project-1:library-a'
in the main settings.gradle
.
Hi, I left a comment above aboutincludeBuild
vsinclude
. From my understanding,includeBuild
is supposed to provide the ability to have a composite build of independent projects. I left a few references to show more examples from the Gradle Github repo.
– mmitchell
Dec 30 '18 at 16:36
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53975344%2fgradle-composite-build-with-custom-gradle-plugin-fails-in-intellij-could-not-f%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Gradle projects can have only one settings.gradle
. You can include subproject "library-a" with include 'project-1:library-a'
in the main settings.gradle
.
Hi, I left a comment above aboutincludeBuild
vsinclude
. From my understanding,includeBuild
is supposed to provide the ability to have a composite build of independent projects. I left a few references to show more examples from the Gradle Github repo.
– mmitchell
Dec 30 '18 at 16:36
add a comment |
Gradle projects can have only one settings.gradle
. You can include subproject "library-a" with include 'project-1:library-a'
in the main settings.gradle
.
Hi, I left a comment above aboutincludeBuild
vsinclude
. From my understanding,includeBuild
is supposed to provide the ability to have a composite build of independent projects. I left a few references to show more examples from the Gradle Github repo.
– mmitchell
Dec 30 '18 at 16:36
add a comment |
Gradle projects can have only one settings.gradle
. You can include subproject "library-a" with include 'project-1:library-a'
in the main settings.gradle
.
Gradle projects can have only one settings.gradle
. You can include subproject "library-a" with include 'project-1:library-a'
in the main settings.gradle
.
answered Dec 30 '18 at 12:33
Axel PAxel P
1,77321425
1,77321425
Hi, I left a comment above aboutincludeBuild
vsinclude
. From my understanding,includeBuild
is supposed to provide the ability to have a composite build of independent projects. I left a few references to show more examples from the Gradle Github repo.
– mmitchell
Dec 30 '18 at 16:36
add a comment |
Hi, I left a comment above aboutincludeBuild
vsinclude
. From my understanding,includeBuild
is supposed to provide the ability to have a composite build of independent projects. I left a few references to show more examples from the Gradle Github repo.
– mmitchell
Dec 30 '18 at 16:36
Hi, I left a comment above about
includeBuild
vs include
. From my understanding, includeBuild
is supposed to provide the ability to have a composite build of independent projects. I left a few references to show more examples from the Gradle Github repo.– mmitchell
Dec 30 '18 at 16:36
Hi, I left a comment above about
includeBuild
vs include
. From my understanding, includeBuild
is supposed to provide the ability to have a composite build of independent projects. I left a few references to show more examples from the Gradle Github repo.– mmitchell
Dec 30 '18 at 16:36
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53975344%2fgradle-composite-build-with-custom-gradle-plugin-fails-in-intellij-could-not-f%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Forgot to mention that I've tried Gradle 4.10.2 and Gralde 4.10.3, and my IntelliJ version is:
IntelliJ IDEA 2018.3.2 (Community Edition) Build #IC-183.4886.37, built on December 17, 2018 JRE: 1.8.0_152-release-1343-b26 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.13.6
– mmitchell
Dec 30 '18 at 4:58
I've updated the README.md in the sample project on Github to show how publishing to maven local allows IntelliJ to successfully load the project. Although IntelliJ itself is unable to publishToMavenLocal due to a duplicate root project name.
– mmitchell
Dec 30 '18 at 6:04
It looks like when you build the main project from command line the
:project-1:library-a
project is not included into build: only onesettings.gradle
is allowed for the Gradle project (and gradle uses only the root's projectsettings.gradle
file). When I importproject-1
project into IDE it also builds fine for me.– Andrey
Dec 30 '18 at 7:18
The approach I'm taking is to use
includeBuild
though, which from the Gradle examples/docs show that projects loaded withincludeBuild
are treated separately. Here's the example I originally followed: github.com/gradle/gradle/tree/master/subprojects/docs/src/… -- and then this one as well: github.com/gradle/gradle/tree/master/subprojects/docs/src/…– mmitchell
Dec 30 '18 at 16:30