Repository: maven
Updated Branches:
  refs/heads/master 44174308a -> aef3b36c0


prepare provides before configuration, to follown descriptor logic

Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/b8d220c6
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/b8d220c6
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/b8d220c6

Branch: refs/heads/master
Commit: b8d220c686ca6a5b8eeed4697ff39d10f9fb0128
Parents: 4417430
Author: Hervé Boutemy <hbout...@apache.org>
Authored: Wed Nov 5 01:23:26 2014 +0100
Committer: Hervé Boutemy <hbout...@apache.org>
Committed: Wed Nov 5 01:23:26 2014 +0100

----------------------------------------------------------------------
 .../java/DefaultJavaToolchainFactory.java       | 49 +++++++++++---------
 1 file changed, 26 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/b8d220c6/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java
----------------------------------------------------------------------
diff --git 
a/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java
 
b/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java
index 3a9d213..d95f2fe 100644
--- 
a/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java
+++ 
b/maven-core/src/main/java/org/apache/maven/toolchain/java/DefaultJavaToolchainFactory.java
@@ -35,7 +35,8 @@ import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 
 /**
- *
+ * JDK toolchain factory.
+ * 
  * @author mkleint
  * @since 2.0.9
  */
@@ -47,10 +48,6 @@ public class DefaultJavaToolchainFactory
     @Requirement
     private Logger logger;
 
-    public DefaultJavaToolchainFactory()
-    {
-    }
-
     public ToolchainPrivate createToolchain( ToolchainModel model )
         throws MisconfiguredToolchainException
     {
@@ -58,36 +55,22 @@ public class DefaultJavaToolchainFactory
         {
             return null;
         }
+
         DefaultJavaToolchain jtc = new DefaultJavaToolchain( model, logger );
-        Xpp3Dom dom = (Xpp3Dom) model.getConfiguration();
-        Xpp3Dom javahome = dom.getChild( DefaultJavaToolchain.KEY_JAVAHOME );
-        if ( javahome == null )
-        {
-            throw new MisconfiguredToolchainException( "Java toolchain without 
the "
-                + DefaultJavaToolchain.KEY_JAVAHOME + " configuration 
element." );
-        }
-        File normal = new File( FileUtils.normalize( javahome.getValue() ) );
-        if ( normal.exists() )
-        {
-            jtc.setJavaHome( FileUtils.normalize( javahome.getValue() ) );
-        }
-        else
-        {
-            throw new MisconfiguredToolchainException( "Non-existing JDK home 
configuration at "
-                + normal.getAbsolutePath() );
-        }
 
-        //now populate the provides section.
+        // populate the provides section
         Properties provides = model.getProvides(); 
         for ( Entry<Object, Object> provide : provides.entrySet() )
         {
             String key = (String) provide.getKey();
             String value = (String) provide.getValue();
+
             if ( value == null )
             {
                 throw new MisconfiguredToolchainException(
                     "Provides token '" + key + "' doesn't have any value 
configured." );
             }
+
             if ( "version".equals( key ) )
             {
                 jtc.addProvideToken( key, 
RequirementMatcherFactory.createVersionMatcher( value ) );
@@ -97,6 +80,26 @@ public class DefaultJavaToolchainFactory
                 jtc.addProvideToken( key, 
RequirementMatcherFactory.createExactMatcher( value ) );
             }
         }
+
+        // populate the configuration section
+        Xpp3Dom dom = (Xpp3Dom) model.getConfiguration();
+        Xpp3Dom javahome = dom.getChild( DefaultJavaToolchain.KEY_JAVAHOME );
+        if ( javahome == null )
+        {
+            throw new MisconfiguredToolchainException( "Java toolchain without 
the "
+                + DefaultJavaToolchain.KEY_JAVAHOME + " configuration 
element." );
+        }
+        File normal = new File( FileUtils.normalize( javahome.getValue() ) );
+        if ( normal.exists() )
+        {
+            jtc.setJavaHome( FileUtils.normalize( javahome.getValue() ) );
+        }
+        else
+        {
+            throw new MisconfiguredToolchainException( "Non-existing JDK home 
configuration at "
+                + normal.getAbsolutePath() );
+        }
+
         return jtc;
     }
 

Reply via email to