intellij-platform-gradle-plugin
intellij-platform-gradle-plugin copied to clipboard
Fail of resolving of compileClasspath configuration with plugins properties
Describe the bug
configurations.compileClasspath.getFiles() fails due to failing of underlying z50_ideaPlugins configuration, when adding com.intellij.java into plugins list.
To Reproduce
plugins {
id 'org.jetbrains.intellij' version '1.13.3'
}
repositories {
mavenCentral()
}
intellij {
version.set("IU-2023.1")
plugins.set(["com.intellij.java"])
}
tasks.register("proguard", Task) {
configurations.compileClasspath.getFiles()
}
Run of proguard task leads to error. In case of removal of plugins.set(["com.intellij.java"]) line - proguard task would be executed with no issues.
Expected behavior compileClassPath configuration is resolved without issues.
Environment:
- OS: Debian Sid
- Gradle IntelliJ Plugin Version 1.13.3
- Gradle Version 8.1
Additional context
configurations.compileClasspath.getFiles() is used for libraryjars from ProGuardTask.
Attaching part of info log.
[gradle-intellij-plugin :] Using IDE from remote repository
The configuration :detachedConfiguration1 is both resolvable and consumable. This is considered a legacy configuration and it will eventually only be possible to be one of these.
The configuration :detachedConfiguration1 is both consumable and declarable. This combination is incorrect, only one of these flags should be set.
The configuration :detachedConfiguration1 is both resolvable and consumable. This is considered a legacy configuration and it will eventually only be possible to be one of these.
The configuration :detachedConfiguration1 is both consumable and declarable. This combination is incorrect, only one of these flags should be set.
[gradle-intellij-plugin :] IDE dependency cache directory: /home/clutcher/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/2023.1/6f24e7c3f8e3f3afd44014d4ade3aba8d78676d6/ideaIU-2023.1
[gradle-intellij-plugin :] Adding IDE sources repository
The configuration :detachedConfiguration2 is both resolvable and consumable. This is considered a legacy configuration and it will eventually only be possible to be one of these.
The configuration :detachedConfiguration2 is both consumable and declarable. This combination is incorrect, only one of these flags should be set.
The configuration :detachedConfiguration2 is both resolvable and consumable. This is considered a legacy configuration and it will eventually only be possible to be one of these.
The configuration :detachedConfiguration2 is both consumable and declarable. This combination is incorrect, only one of these flags should be set.
[gradle-intellij-plugin :] IU-231.8109.175 is used for building
[gradle-intellij-plugin] Resolving Gradle IntelliJ Plugin version with: jar:file:/home/clutcher/.gradle/caches/modules-2/files-2.1/org.jetbrains.intellij.plugins/gradle-intellij-plugin/1.13.3/cafdaec493e138370418189db764f2fd0cf6803/gradle-intellij-plugin-1.13.3.jar!/META-INF/MANIFEST.MF
[gradle-intellij-plugin] Resolving Gradle IntelliJ Plugin version with: jar:file:/home/clutcher/.gradle/caches/modules-2/files-2.1/org.jetbrains.intellij.plugins/gradle-intellij-plugin/1.13.3/cafdaec493e138370418189db764f2fd0cf6803/gradle-intellij-plugin-1.13.3.jar!/META-INF/MANIFEST.MF
[gradle-intellij-plugin] Resolving Gradle IntelliJ Plugin version with: jar:file:/home/clutcher/.gradle/caches/modules-2/files-2.1/org.jetbrains.intellij.plugins/gradle-intellij-plugin/1.13.3/cafdaec493e138370418189db764f2fd0cf6803/gradle-intellij-plugin-1.13.3.jar!/META-INF/MANIFEST.MF
[gradle-intellij-plugin] Resolving Gradle IntelliJ Plugin version with: jar:file:/home/clutcher/.gradle/caches/modules-2/files-2.1/org.jetbrains.intellij.plugins/gradle-intellij-plugin/1.13.3/cafdaec493e138370418189db764f2fd0cf6803/gradle-intellij-plugin-1.13.3.jar!/META-INF/MANIFEST.MF
[gradle-intellij-plugin] Resolving Gradle IntelliJ Plugin version with: jar:file:/home/clutcher/.gradle/caches/modules-2/files-2.1/org.jetbrains.intellij.plugins/gradle-intellij-plugin/1.13.3/cafdaec493e138370418189db764f2fd0cf6803/gradle-intellij-plugin-1.13.3.jar!/META-INF/MANIFEST.MF
[gradle-intellij-plugin] Resolving Gradle IntelliJ Plugin version with: jar:file:/home/clutcher/.gradle/caches/modules-2/files-2.1/org.jetbrains.intellij.plugins/gradle-intellij-plugin/1.13.3/cafdaec493e138370418189db764f2fd0cf6803/gradle-intellij-plugin-1.13.3.jar!/META-INF/MANIFEST.MF
The configuration :mainSourceElements is both consumable and declarable. This combination is incorrect, only one of these flags should be set.
[gradle-intellij-plugin :] Configuring plugin dependencies
[gradle-intellij-plugin :] Configuring plugin: com.intellij.java
[gradle-intellij-plugin :] Looking for builtin 'com.intellij.java' in: /home/clutcher/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/2023.1/6f24e7c3f8e3f3afd44014d4ade3aba8d78676d6/ideaIU-2023.1
FAILURE: Build failed with an exception.
* Where:
Build file '/home/clutcher/projects/better_highlights/build.gradle' line: 19
* What went wrong:
A problem occurred configuring root project 'better_highlights'.
> Could not create task ':proguard'.
> DefaultTaskCollection#configureEach(Action) on task set cannot be executed in the current context.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 810ms
Workaround I used for real proguard task, just in case someone has similar issue.
try {
libraryjars(configurations.compileClasspath.getFiles())
} catch (Exception e) {
logger.error("Were not able to resolve complileClasspath. Fallback to z90_intellij.")
libraryjars(configurations.z10_intellijDefaultDependencies.getFiles())
libraryjars(configurations.z90_intellij.getFiles())
String ideaPath = configurations.z90_intellij.getFiles()[0].getParentFile().getParentFile().getAbsolutePath()
file("$ideaPath/plugins/java/lib").listFiles().each {
libraryjars(it)
}
}
In case you have more core plugins or some generic/cusomt plugins, you should find their path and add manually. Below example with Java and Javascript core plugins + PHP and Python generic plugins.
try {
libraryjars(configurations.compileClasspath.getFiles())
} catch (Exception e) {
logger.error("Were not able to resolve complileClasspath. Fallback to z90_intellij.")
// Add intellij platform
libraryjars(configurations.z10_intellijDefaultDependencies.getFiles())
libraryjars(configurations.z90_intellij.getFiles())
// Add intellij plugins
File ideaPathFile = configurations.z90_intellij.getFiles()[0].getParentFile().getParentFile()
String ideaPath = ideaPathFile.getAbsolutePath()
file("$ideaPath/plugins/java/lib").listFiles().each {
libraryjars(it)
}
file("$ideaPath/plugins/javascript-impl/lib").listFiles().each {
libraryjars(it)
}
String additionalPluginsPath = ideaPathFile.getParentFile().getParentFile().getParentFile().getParentFile().getAbsolutePath()
file("$additionalPluginsPath/unzipped.com.jetbrains.plugins/Pythonid-231.8109.175/python/lib").listFiles().each {
libraryjars(it)
}
file("$additionalPluginsPath/unzipped.com.jetbrains.plugins/com.jetbrains.php-231.8109.199/php-impl/lib").listFiles().each {
libraryjars(it)
}
}
Thanks for filling the issue. It should be resolved with dependencies/repositories management refactoring in 2.0 release.
In your workaround, please use the following constant instead of hardcoded configuration name:
https://github.com/JetBrains/gradle-intellij-plugin/blob/e23fa587e1b780641c25c647700235131d7fa4b3/src/main/kotlin/org/jetbrains/intellij/IntelliJPluginConstants.kt#L89
@hsz Thanks for fast response.
Is it possible to put some workaround into on of the nearest releases? For example, output warning insead of failing whole compileClasspath resolving? Or put some configuration option skip/disable z50_ideaPlugins? Or maybe provide separate method/variable to get path to directories with .jars? etc.
With the IntelliJ Platform Gradle Plugin 2.0, the IntelliJ Platform along with all plugins (bundled or plugins from JetBrains Marketplace) are added to the project as regular dependencies in the configuration phase.
With that approach, ProGuard can easily refer to the compileClasspath configuration, which should now be complete.
See: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html