Home > Mobile >  IntielliJ is using folder "${project.build.directory}" instead of "target" as ma
IntielliJ is using folder "${project.build.directory}" instead of "target" as ma

Time:11-19

I want intellij to go back to using target.

On 2022-10-24 a new folder appeared in my project that was literally named ${project.build.directory}. I was busy so I ignored and .gitgignored this for awhile but I finally found time to examine it today. It turns out, Intellij is now using this to store and run class files, and the class files in target are out of date.

  1. When I run mvn compile, the .class files are deposited in target.
  2. When I run build or test in IntelliJ, the the .class files are created in the folder named `${project.build.directory}'.
  3. Anything in my target/generated-sources folder is copied into the folder named ${project.build.directory}/classes.

I did a check on pom.xml and it has not been changed since May.

I compared .idea/compiler.xml with a pre-October version of the file and there have been no changes.

I am running Java 17.0.1 installed by homebrew in 10-2021, Maven 3.8.4, and IntelliJ IDEA 2021.2.4 Ultimate edition which was reportedly built 2021-12-21. I was running a September install of MacOS 12.6 on October 24 and have since upgraded to 13.0. The IntelliJ Maven plugin has a "bundled" number of 212.5712.43.

Maven plugin settings should be defaults, as below: maven plugin settings

compiler settings

Anything else I can check to understand this behavior? I know that project.build.directory is a maven identifier, but it does not appear in my pom.xml and in any case, maven appears to be working just fine.

CodePudding user response:

The problem could not be reproduced after recreating the folder from time machine, from source control, and also by manually copying in the contents. Git was unable to detect any difference between the problem folder and the restored folders, however, intelliJ's problem behavior continued with the original folder. Perhaps intellij uses some kind of hidden semaphore system that is not captured in source control.

Because I am trying to create a smooth experience for beginning users, I was not happy to not be able to find a root cause of the issue but alas IntelliJ is a black box and there is no way for me to see what is actually going on. Per Git the problem folder and the recovered folder were identical.

Bottom line:

Simply copying the project folder using the finder did not resolve the issue. Copying the project folder content to a new project folder resolved the issue.

  • copy the entire project folder using some method
  • delete the original project folder
  • create a new folder for the project
  • copy the nested content of the copy into the new folder using some method
  • Related