spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.28k stars 37.98k forks source link

Difficutly building source code in IntelliJ #26345

Closed yuyu414 closed 3 years ago

yuyu414 commented 3 years ago

Import the project into IDEA, and this is the result of Gradle's compilation.

exception during working with external system: java.lang.AssertionError
    at org.jetbrains.plugins.gradle.service.project.BaseGradleProjectResolverExtension.createModule(BaseGradleProjectResolverExtension.java:154)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.kotlin.idea.configuration.KotlinMPPGradleProjectResolver.createModule(KotlinMPPGradleProjectResolver.kt:67)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at com.android.tools.idea.gradle.project.sync.idea.AndroidGradleProjectResolver.createModule(AndroidGradleProjectResolver.java:165)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.kotlin.android.configure.KotlinAndroidMPPGradleProjectResolver.createModule(KotlinAndroidMPPGradleProjectResolver.kt:45)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86)
    at org.jetbrains.plugins.gradle.service.project.TracedProjectResolverExtension.createModule(TracedProjectResolverExtension.java:45)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:344)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$200(GradleProjectResolver.java:60)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:725)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:708)
    at org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.execute(GradleExecutionHelper.java:278)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:125)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:60)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.lambda$resolveProjectInfo$0(RemoteExternalSystemProjectResolverImpl.java:35)
    at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:57)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:35)
    at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:44)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:100)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:146)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:132)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.executeImpl(ExternalSystemUtil.java:540)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.lambda$execute$1(ExternalSystemUtil.java:392)
    at com.intellij.openapi.project.DumbServiceImpl.suspendIndexingAndRun(DumbServiceImpl.java:150)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:392)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$5.run(ExternalSystemUtil.java:647)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:888)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:163)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:585)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:531)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:150)
    at com.intellij.openapi.progress.impl.CoreProgressManager$4.lambda$run$0(CoreProgressManager.java:402)
    at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:221)
    at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:402)
    at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:238)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
sbrannen commented 3 years ago

I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference.

sbrannen commented 3 years ago

Have you followed the instructions the following documents?

yuyu414 commented 3 years ago

I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference.

yes,Thank you. That's what I need

yuyu414 commented 3 years ago

Have you followed the instructions the following documents?

I'll try。 building spring-framework-5.3.2 ,Is it related to gradle version or jdk version?

sbrannen commented 3 years ago

building spring-framework-5.3.2 ,

If you are building from the master branch, you are actually building 5.3.3 snapshots.

Is it related to gradle version or jdk version?

As stated in the Build from Source page:

To build you will need Git and JDK 8 update 262 or later. Update 262 or later is required due to the dependency on Java Flight Recorder (JFR) types. Note, however, that Oracle JDKs do not include the JFR types. Thus, we recommend an AdoptOpenJDK distribution or similar that includes the JFR types.

The version of Gradle is managed automatically via the Gradle Wrapper. That's why you need to use ./gradlew to execute Gradle instead of ./gradle.

yuyu414 commented 3 years ago

execute gradlew build

Starting a Gradle Daemon, 2 incompatible and 1 stopped Daemons could not be reused, use --status for details

> Task :spring-tx:compileKotlin
Could not perform incremental compilation: Could not connect to Kotlin compile daemon
Could not connect to kotlin daemon. Using fallback strategy.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jetbrains.kotlin.com.intellij.util.ReflectionUtil (file:/C:/Users/vaio/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler-e
mbeddable/1.4.21/87db94500aaf883536ae8c8efdee76bdc839d582/kotlin-compiler-embeddable-1.4.21.jar) to method java.util.ResourceBundle.setParent(java.util.ResourceBundle)
WARNING: Please consider reporting this to the maintainers of org.jetbrains.kotlin.com.intellij.util.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

> Task :spring-tx:compileJava
Could not load entry 7bf6fd88d2901ffe21dd5328a3673e85 from remote build cache: Read timed out

> Task :spring-beans:test
Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

> Task :spring-core:test
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.util.ReflectionUtils (file:/C:/Users/vaio/Desktop/learn-spring-framework/spring-core/build/classes/java/main/) to constructor ja
va.util.AbstractList()
WARNING: Please consider reporting this to the maintainers of org.springframework.util.ReflectionUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

> Task :spring-expression:compileTestJava

> Task :spring-core:test

StopWatchTests > validUsage() FAILED
    java.lang.AssertionError at StopWatchTests.java:107

3324 tests completed, 1 failed, 13 skipped

> Task :spring-core:test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':spring-core:test'.
> There were failing tests. See the report at: file:///C:/Users/vaio/Desktop/learn-spring-framework/spring-core/build/reports/tests/test/index.html

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 17m 1s
174 actionable tasks: 145 executed, 29 from cache
The remote build cache was disabled during the build due to errors.
yuyu414 commented 3 years ago

building spring-framework-5.3.2 ,

If you are building from the master branch, you are actually building 5.3.3 snapshots.

Is it related to gradle version or jdk version?

As stated in the Build from Source page:

To build you will need Git and JDK 8 update 262 or later. Update 262 or later is required due to the dependency on Java Flight Recorder (JFR) types. Note, however, that Oracle JDKs do not include the JFR types. Thus, we recommend an AdoptOpenJDK distribution or similar that includes the JFR types.

The version of Gradle is managed automatically via the Gradle Wrapper. That's why you need to use ./gradlew to execute Gradle instead of ./gradle.

OK,I used tags:v5.3.2

sbrannen commented 3 years ago

StopWatchTests > validUsage() FAILED java.lang.AssertionError at StopWatchTests.java:107

Line 107 in StopWatchTests performs an assertion based on timing which may have failed due to load on your machine.

Execute the build again via ./gradlew build to see if it passes.

yuyu414 commented 3 years ago

StopWatchTests > validUsage() FAILED java.lang.AssertionError at StopWatchTests.java:107

Line 107 in StopWatchTests performs an assertion based on timing which may have failed due to load on your machine.

Execute the build again via ./gradlew build to see if it passes.

After many attempts, the problem remains the same。

ttddyy commented 3 years ago

@yuyu414 I just imported the project with v5.3.2 tag to IntelliJ. "Build Project" and "Rebuild Project" on IDE works as expected.

Here is how I did:

> git clone https://github.com/spring-projects/spring-framework.git
> cd spring-framework
> git checkout v5.3.2
> sdk use java 11.0.5-zulu
> ./gradlew build -x test

After successful build, import to intellij

Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)

Configure IDE to match with JDK version
- Project SDK
- Project language level
- Project bytecode version

IntelliJ: 2020.3 & 2020.3.1.

I don't think building on IDE runs any tests. So, where are you getting the error? If it is from command line gradlew, then it is not related to IDE.

Also, you can simply skip test in order to import the project to IntelliJ. Passing tests is not a requirement to import into IntelliJ.

yuyu414 commented 3 years ago

@yuyu414 I just imported the project with v5.3.2 tag to IntelliJ. "Build Project" and "Rebuild Project" on IDE works as expected.

Here is how I did:

> git clone https://github.com/spring-projects/spring-framework.git
> cd spring-framework
> git checkout v5.3.2
> sdk use java 11.0.5-zulu
> ./gradlew build -x test

After successful build, import to intellij

Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)

Configure IDE to match with JDK version
- Project SDK
- Project language level
- Project bytecode version

IntelliJ: 2020.3 & 2020.3.1.

I don't think building on IDE runs any tests. So, where are you getting the error? If it is from command line gradlew, then it is not related to IDE.

Also, you can simply skip test in order to import the project to IntelliJ. Passing tests is not a requirement to import into IntelliJ.

I did the same thing,it is from command line gradlew. I live in China,Maybe I can't use gradle properly because of the blocking policy of the government's overseas network!

yuyu414 commented 3 years ago

I'll take care of this. Thank you (ttddyy and sbrannen). I'm going to close it。