Main Tutorials

Maven site build is very slow – dependency report

Creating a Maven site, but the build is very slow to generate the dependency report.


C:\mkyong_projects\>mvn site
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------------------
[INFO] Building Maven Webapp 1.0-SNAPSHOT
[INFO] --------------------------------------
[INFO]
//...
[INFO] Generating "Project License" report
[INFO] Generating "Project Team" report 
[INFO] Generating "Project Summary" report
[INFO] Generating "Dependencies" report
//...... Hanging here...

1. Trace

Maven debug it with option -X, when generate the dependency report, it keeps open connections to other websites.


C:\mkyong_projects\>mvn -X site
//...
http://google-gson.googlecode.com/svn/mavenrepo - Session: Opened
http://google-gson.googlecode.com/svn/mavenrepo - Session: Disconnecting
http://google-gson.googlecode.com/svn/mavenrepo - Session: Disconnected
http://files.couchbase.com/maven2/ - Session: Opened
http://files.couchbase.com/maven2/ - Session: Disconnecting
http://files.couchbase.com/maven2/ - Session: Disconnected
http://repo.maven.apache.org/maven2 - Session: Opened
http://repo.maven.apache.org/maven2 - Session: Disconnecting
http://repo.maven.apache.org/maven2 - Session: Disconnected
http://repository.jboss.org/nexus/content/groups/public/ - Session: Opened
http://repository.jboss.org/nexus/content/groups/public/ - Session: Disconnecting
http://repository.jboss.org/nexus/content/groups/public/ - Session: Disconnected

//... Long list, seem like never end

2. Solution

Above project is using too many third party libraries (which Java project doesn’t?), resolve too many dependencies caused the slow building. To solve it, skip the dependency report generation.

Solution 1
Build it offline with option -o, dependency report will be ignored.


C:\mkyong_projects\>mvn -o site
//...
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------------------
[INFO] Building Maven Webapp 1.0-SNAPSHOT
[INFO] --------------------------------------
[INFO]
//...
[INFO] Generating "Project License" report
[INFO] Generating "Project Team" report 
[INFO] Generating "Project Summary" report
[INFO] Generating "Dependencies" report
[WARNING] The parameter 'dependencyLocationsEnabled' is ignored in offline mode.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.428s
[INFO] Finished at: Thu Jan 09 22:21:53 SGT 2014
[INFO] Final Memory: 52M/706M

Solution 2
Declares the “maven-project-info-reports-plugin” in reporting section, and set dependencyLocationsEnabled to false. When creating the Maven site, dependency report generation will be skipped.

pom.xml

  <reporting>
    <plugins>
		
	<plugin>
		<groupId>org.apache.maven.plugins</groupId>
		<artifactId>maven-project-info-reports-plugin</artifactId>
		<version>2.7</version>

		<configuration>
		  <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
		</configuration>
	</plugin>
        	
    </plugins>
  </reporting>

References

  1. Maven – Creating a site
  2. In Maven 2, how do I know from which dependency comes a transitive dependency?

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Pram
9 years ago

It worked! I followed your tutorial and the compile time is reduced from 2 minutes to 19 seconds.. Thanks!!

mkyong
9 years ago
Reply to  Pram

yeah, good to know it.