0

My Maven installation recently started taking a very long time to compile projects. A project with a single source file takes almost 4 minutes to compile on my system, when I was able to previously build projects with over 100 source files in less than two minutes. I'm not sure what I've done to cause this issue. My only theory so far is that it concerns the local.repository directory Maven seems to use during the build process, as I mistakenly deleted this folder (?) on account of the fact that it appeared empty and useless.

My attempts to remedy the issue so far have included upgrading my Maven build to 3.1, restarting my machine, deleting the maven cache `(~/.m2/) and increasing the amount of memory available to Maven as described in here.

The output of my build:

    [INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my-app ---
[INFO] Deleting /Users/alexwood/Software_Development/Projects/Maven Tutorial/my-app/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my-app ---
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/alexwood/Software_Development/Projects/Maven Tutorial/my-app/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ my-app ---
[WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /Users/alexwood/Software_Development/Projects/Maven Tutorial/my-app/target/classes

My Maven version information:

Apache Maven 3.1.0 (893ca28a1da9d5f51ac03827af98bb730128f9f2; 2013-06-27 19:15:32-0700)
Maven home: /usr/local/Cellar/maven/3.1.0/libexec
Java version: 1.6.0_51, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"

The pom.xml file I'm using:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-  instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<dependencies>
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
  </dependency>
</dependencies>

Any help would be much appreciated. If I can provide any further clarification, please let me know.

6
  • 3
    if you have deleted .m2 directory, then you have also deleted the whole local repository. This means that maven will now download any plugin and all needed dependencies for your projects again, which might explain why it takes longer to build. Usually the more projects you do the more dependencies you collect in the local repo and maven doesn't need to fetch them again. Commented Jul 22, 2013 at 19:24
  • Understood, but the problem I'm describing occurs during the compile step after the project's dependencies have been downloaded. The long compile time persists even after maven has downloaded all of the project's dependencies. Commented Jul 22, 2013 at 19:26
  • you can try to compile without maven and see if it is faster. Do you run mvn compile or some other lifecycle? Commented Jul 22, 2013 at 19:30
  • I run mvn clean install, but mvn compile alone seems to have the same problem. Commented Jul 22, 2013 at 19:34
  • try mvn -X clean install. Perhaps you'll get some more information. Commented Jul 22, 2013 at 20:40

1 Answer 1

2

The problem ended up being JDK related. A reinstallation of the latest Java release for my system resolved the issue.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.