Maven3 parallel execution support in Sakai Maven Plugin

Description

Maven3 supports parallel builds which can dramatically increase build times. Maven analyses the projects and executes the plugins accordingly. Almost all CPU's are multicored these days and we can take advantage of that to save time on builds.

For example the following command will spawn 4 threads to build:

mvn clean install -T 4

And the following will spawn two threads per cpu core:

mvn clean install -T 2C

Currently you get the following:

[WARNING] *****************************************************************
[WARNING] * Your build is requesting parallel execution, but project *
[WARNING] * contains the following plugin(s) that are not marked as *
[WARNING] * @threadSafe to support parallel building. *
[WARNING] * While this /may/ work fine, please look for plugin updates *
[WARNING] * and/or request plugins be made thread-safe. *
[WARNING] * If reporting an issue, report it against the plugin in *
[WARNING] * question, not against maven-core *
[WARNING] *****************************************************************
[WARNING] The following plugins are not marked @threadSafe in project_name:
[WARNING] org.sakaiproject.maven.plugins:sakai:1.2.0
[WARNING] *****************************************************************

===========================================================================
https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3

Mojo thread safety assertion checklist
Sometimes it can be hard to determine if a plugin and the underlying libraries are thread-safe, so when adding @threadSafe the following checklist can be used:

  • Check all static fields/variables in plugin/plugin code are not subject to threading problems.

  • You might want to pay special attention to static member variables of the subclasses of "java.text.Format" (NumeberFormat, DateFormat etc), most of which
    are not threadsafe and cannot be shared as static variables.

  • Check any plexus components.xml; if the components defined are singletons they need to be threadsafe.

  • Check for presence of known tainted libraries.

  • Check thread safety of any other third party libraries. This last item can be a bit hard, but inquiries on mailing lists can get you a long way.

This checklist qualifies for a "simple thread safety" review of a mojo.

If a mojo uses a known-non-threadsafe external dependency, you may want to do something like this:

public class MyMojo
extends AbstractMojo
{

private static final Object lock = new Object();

public void execute()
{
synchronized( lock)
{
// Main mojo code
}
}
}

Attachments

1
  • 18 Jul 2011, 04:58 AM

is related to

Activity

Christopher Maurer May 16, 2013 at 10:58 AM

Me might need someone (Matt Jones) to do a release of the plugin if it's all ready.

Hudson CI Server May 10, 2013 at 7:40 AM

Integrated in sakai-maven-plugin trunk #31 (See http://builds.sakaiproject.org:8080/job/sakai-maven-plugin%20trunk/31/)
https://sakaiproject.atlassian.net/browse/SMP-16#icft=SMP-16 Upgrade dependencies to allow threadsafe builds.

Although the sakai maven plugin had been marked as threadsafe, it's dependencies weren't marked as threadsafe which was causing a warning to still be issued when doing the build. (Revision 123943)

Result = SUCCESS

Matthew Buckett May 10, 2013 at 7:04 AM

I've committed a fix to trunk of the Sakai Maven Plugin (upgraded plexus-utils and maven-archiver.

Once a snapshot gets built and deployed you should be able to upgrade your master/pom.xml to version 1.4.2-SNAPSHOT to get the fixed plugin and you should no longer get warning from the sakai plugin.

Matthew Buckett May 10, 2013 at 6:52 AM

I think this is because the sakai plugin depends on plugins that aren't threadsafe upgrading the dependencies looks to fix it.

David Poindexter March 9, 2013 at 12:12 PM

Any further movement on this?

Fixed

Details

Assignee

Reporter

Fix versions

Priority

Created July 18, 2011 at 4:02 AM
Updated September 14, 2015 at 10:46 AM
Resolved May 10, 2013 at 8:28 AM