Unable to build maven projects from Build > Build Project for completely empty project

Answered

I have been facing issues with intellij in that it is completely unable to build/rebuild any maven projects from the IDE. The projects were building fine from terminal mvn commands and even via Add New Configuration > maven options. However the fact the the IDE itself never compiled the code I could not run any junit tests by right click > run test options. I have recreated this issue with completely empty maven project with one class and one test class with only junit as a dependency. 

Below are the steps;

 

  • File > New > Project.. > maven
  • Click next without any archtype selection and create the project. It should create empty project with no dependencies and no classes
  • Add junit 4.12 dependency. the resultant pom looks like this;
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
  • create a test class called MainTest in package org.example in src/test/java

MainTest.java

package org.example;

import org.junit.Test;

public class MainTest {
@Test
public void testIt(){
System.out.println("Something");
}
}
  • Try Build > Build/Rebuild Project. It starts to fail with below errors suggesting it is unable to resolve the junit dependency

 

Below are some of my project and intellij settings screenshots.

Project Structure > Project 

Project Structure > Modules > Sources

Project Structure > Modules > Dependencies 

Projects tab

 

Intellij version

I am getting code completion just fine in the IDE an able to see all the dependencies in the external libraries section which suggest there isn't any problem with the maven resolving. This seems to be only problem which I try to build the project or run the test with junit from IDE.

 

Can someone please throw any pointers on this and suggest what could be wrong? let me know if any additional details are required

1
6 comments

Thank you for the detailed information. Please try to perform the following steps:

0
Avatar
Permanently deleted user

Hi I have now tried all of the given steps multiple times however none of them helped. Is there anything else I could check/try for this issue?

0

@...,

The problem is not reproduced for my work environment. Try to restore default IntelliJ IDEA settings. (File | Manage IDE Settings | Restore Default Settings...)

If the problem remains, please attach a sample project and a compressed log folder after restarting the IDE and reproducing the problem. The files can be uploaded via uploading service or any other resources. Please do not forget to specify the Upload ID.

1
Avatar
Permanently deleted user

Thanks for the answer Egor Klepikov

I was facing the same issue reported by  @.... After I restored my Intellij IDEA to default settings, as you said, my issue was resolved and I could build my projects from the IDE,

0
Avatar
Permanently deleted user

Restoring default settings helped me as well.

I had been installing quarterly updates for about 3 years at this point.

0

It helped me as well

0

Please sign in to leave a comment.