intellij-platform-gradle-plugin icon indicating copy to clipboard operation
intellij-platform-gradle-plugin copied to clipboard

NoSuchFileException: build/tmp/initializeIntelliJPlugin/coroutines-javaagent.jar

Open hfhbd opened this issue 7 months ago • 5 comments

What happened?

I get NoSuchFileException: build/tmp/initializeIntelliJPlugin/coroutines-javaagent.jar when running ./gradlew clean build multiple times after updating to 1.16, it was introduced in 1.16 though.

This error is persistent, even running clean does not help, nor deleting the .gradle or build folder. Only workaround I found is downgrading to 1.15.

This won't happen on CI because it is only executed once.

Relevant log output or stack trace

Caused by: java.nio.file.NoSuchFileException: /Users/philipwedemann/GitHub/kobol/intellij-plugin/build/tmp/initializeIntelliJPlugin/coroutines-javaagent.jar
        at com.jetbrains.plugin.structure.base.utils.FileUtilKt.outputStream(FileUtil.kt:38)
        at org.jetbrains.intellij.tasks.InitializeIntelliJPluginTask.createCoroutinesJavaAgentFile(InitializeIntelliJPluginTask.kt:95)
        at org.jetbrains.intellij.tasks.InitializeIntelliJPluginTask.initialize(InitializeIntelliJPluginTask.kt:51)

Steps to reproduce

  1. Checkout https://github.com/hfhbd/kobol/tree/reproducer
  2. Run ./gradlew clean build, a compilekotlin error is expected
  3. Run ./gradlew clean build

Don't be afraid of the size of the project, I am just too lazy to delete the code, but other projects are disabled.

Gradle IntelliJ Plugin version

1.16.0

Gradle version

8.4

Operating System

macOS

Link to build, i.e. failing GitHub Action job

No response

hfhbd avatar Nov 13 '23 21:11 hfhbd

Instead of build, use buildPlugin task.

hsz avatar Nov 29 '23 12:11 hsz

This also does not work: https://scans.gradle.com/s/mapibsleenhye

hfhbd avatar Nov 29 '23 12:11 hfhbd

I'm using .\gradlew.bat clean buildPlugin throw the error too: coroutines-javaagent.jar not found

idea U 2023.3 plugin 1.17.1(1.61.1 as same)+gradle 8.5

zhyhang avatar Feb 08 '24 08:02 zhyhang

Change the config from org.gradle.configuration-cache = true to org.gradle.configuration-cache = false (in gradle.properties), the problem resolved.

zhyhang avatar Feb 08 '24 09:02 zhyhang

I also noticed a related problem.

Show Gradle console output
Calculating task graph as configuration cache cannot be reused because the file system entry 'build\classes\java\main\classpath.index' has been created.
> Task :plugins:checkKotlinGradlePluginConfigurationErrors
> Task :plugins:generateExternalPluginSpecBuilders UP-TO-DATE
> Task :plugins:extractPrecompiledScriptPluginPlugins UP-TO-DATE
> Task :plugins:compilePluginsBlocks UP-TO-DATE
> Task :plugins:generatePrecompiledScriptPluginAccessors UP-TO-DATE
> Task :plugins:generateScriptPluginAdapters UP-TO-DATE
> Task :plugins:compileKotlin UP-TO-DATE
> Task :plugins:compileJava NO-SOURCE
> Task :plugins:pluginDescriptors UP-TO-DATE
> Task :plugins:processResources UP-TO-DATE
> Task :plugins:classes UP-TO-DATE
> Task :plugins:jar UP-TO-DATE
> Task :initializeIntelliJPlugin SKIPPED
> Task :clean
> Task :processTestResources NO-SOURCE
> Task :patchPluginXml FROM-CACHE
> Task :generateLexer FROM-CACHE
> Task :verifyPluginConfiguration
> Task :processResources
> Task :generateParser FROM-CACHE
> Task :compileJava FROM-CACHE
> Task :classes
> Task :instrumentCode FROM-CACHE
> Task :instrumentedJar FROM-CACHE
> Task :compileTestJava FROM-CACHE
> Task :testClasses UP-TO-DATE
> Task :instrumentTestCode FROM-CACHE
> Task :classpathIndexCleanup
> Task :jar
> Task :prepareTestingSandbox
> Task :test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':test' (type 'Test').
  - Type 'org.gradle.api.tasks.testing.Test' property 'jvmArgumentProviders.$0.coroutinesJavaAgentPath' specifies file 'C:\Users\jojo\Entwicklung\nix-idea\build\tmp\initializeIntelliJPlugin\coroutines-javaagent.jar' which doesn't exist.
    
    Reason: An input file was expected to be present but it doesn't exist.
    
    Possible solutions:
      1. Make sure the file exists before the task is called.
      2. Make sure that the task which produces the file is declared as an input.
    
    For more information, please refer to https://docs.gradle.org/8.6/userguide/validation_problems.html#input_file_does_not_exist in the Gradle documentation.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

As can be seen in the console output, :clean may be executed after :initializeIntelliJPlugin. Since :initializeIntelliJPlugin is creating the coroutines-javaagent.jar, the file may be missing during later task executions. I guess the problem is that InitializeIntelliJPluginTask does not declare any output files, but instead stores the output in the directory returned by Task.getTemporaryDir. Note that the Javadoc of this method explicitly mentions that you should not use the content of the directory outside the specific task:

There are no guarantees that the contents of this directory will be kept beyond the execution of the task.

@hsz Can you consider re-opening this issue?

After declaring the outputs correctly, maybe you could also enable caching for this task to resolve #1554?

JojOatXGME avatar Mar 31 '24 01:03 JojOatXGME