How to rebuild project structure libraries?

Answered

 I have a complex project with lots of libraries and accidentally removed one library. How can i revert this / rebuild the project structure?

Gradle builds work fine but Intellij build fails.

 

Thanks!

0
9 comments
Avatar
Permanently deleted user

I may have to add: It was a Gradle library I removed. The empty entry is still missing in Project Structure->Libraries but classes and source are missing.

 

Gradle refresh does not work.

0

Delete .idea directory and reimport from build.gradle.

0
Avatar
Permanently deleted user

Nevermind. Gradle refresh did work, but i had to select the specific Gradle (sub)project for refreshing external libs.

Seems like Intellij's "Refresh all Gradle Projects" does not work if one project contains multiple sub-projects with own dependencies.

 

0
Avatar
Permanently deleted user

Update, fastest solution i fond:

1. In "Gradle Projects" right-click->Detach external project.

2. File->New->Module from existing sources. And reimport the project.

This works better than "right-click->Refresh external project" for 30+ sub-projects.

Would be good if Gradle support could be improved here. Thanks anyway.

1
Avatar
Vladislav Soroka

'Refresh Gradle project' should create/restore project structure for all modules of the gradle <multi->project.
'Refresh all Gradle projects' should create/restore project structure for all gradle modules in the IntelliJ project.
(Note, there can be more than one gradle multiprojects linked to the single IntelliJ project)

Could you describe the steps to reproduce (ideally with the project sample attached) the issue you encountered?

Thanks in advance!

0
Avatar
Permanently deleted user

I'm afraid I cannot disclose the company/product/code I'm working for.

I had general problems with Gradle Sync (Gradle assemble tasks were working, IntelliJ builds did not due to not updated libraries) but right now it's working fine.

auto-import did also not work, but is enabled now.

I will come back here if I encounter problems again.

 

 

0
Avatar
Permanently deleted user
 
Ok, build error again. Basic structure is
 
- main-module/main-gradle-project
-- gradle-subproject1
--- gradle-subsubproject1
---- src/test/java/foo/Clazz1.java
--- gradle-subsubproject2
---- src/test/java/foo/Clazz2.java
 
IntelliJ build says it cannot find Clazz2 used by Clazz1 - they are in the same package, so no import statement. However, the editor does not show any error, the navigation from Clazz1 to Clazz2 works and all Gradle tasks are building successful. All Gradle projects (2 others besides the main module) are with auto-import enabled and "Refresh all gradle projects" was tried.
 
(I would skip the IntelliJ build alltogether but running tests with Gradle test runner always says "Test events were not received")
 
Any help appreciated.
0
Avatar
Permanently deleted user

... And "fixed" again after "gradle clean assemble" in the main project.

But this takes long and is annoying. I can give more specific information if you tell me what you need.

0

Please sign in to leave a comment.