]> source.dussan.org Git - archiva.git/commitdiff
avoid failing on java profile or other profiles by using a TwoPhaseBuiling maven...
authorOlivier Lamy <olamy@apache.org>
Sat, 25 Feb 2012 20:45:18 +0000 (20:45 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 25 Feb 2012 20:45:18 +0000 (20:45 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1293680 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java

index b1a1f78ce29061e85b7c3f96ec24a3851b8c6850..503a52b765bc84a7e7dfcd3bef32aa7f831dc351 100644 (file)
@@ -43,6 +43,7 @@ import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeEx
 import org.apache.archiva.proxy.common.WagonFactory;
 import org.apache.archiva.reports.RepositoryProblemFacet;
 import org.apache.archiva.xml.XMLException;
+import org.apache.commons.lang.StringUtils;
 import org.apache.maven.model.CiManagement;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.IssueManagement;
@@ -131,6 +132,7 @@ public class Maven2RepositoryStorage
     {
         DefaultModelBuilderFactory defaultModelBuilderFactory = new DefaultModelBuilderFactory();
         builder = defaultModelBuilderFactory.newInstance();
+
     }
 
     public ProjectMetadata readProjectMetadata( String repoId, String namespace, String projectId )
@@ -217,15 +219,17 @@ public class Maven2RepositoryStorage
                 }
             }
 
-            ModelBuildingRequest req = new DefaultModelBuildingRequest();
-            req.setProcessPlugins( false );
-            req.setPomFile( file );
+            ModelBuildingRequest req =
+                new DefaultModelBuildingRequest()
+                    .setProcessPlugins( false )
+                    .setPomFile( file )
+                    .setTwoPhaseBuilding( true )
+                    .setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
 
             // MRM-1411
             req.setModelResolver(
                 new RepositoryModelResolver( basedir, pathTranslator, wagonFactory, remoteRepositories, networkProxies,
                                              repositoryConfiguration ) );
-            req.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
 
             Model model;
             try
@@ -241,8 +245,11 @@ public class Maven2RepositoryStorage
                 {
                     // MRM-1411, related to MRM-1335
                     // this means that the problem was that the parent wasn't resolved!
-                    if ( problem.getException() instanceof FileNotFoundException && e.getModelId() != null &&
-                        !e.getModelId().equals( problem.getModelId() ) )
+                    // olamy really hackhish but fail with java profile so use error message
+                    // || ( StringUtils.startsWith( problem.getMessage(), "Failed to determine Java version for profile" ) )
+                    // but setTwoPhaseBuilding(true) fix that
+                    if ( ( problem.getException() instanceof FileNotFoundException && e.getModelId() != null &&
+                        !e.getModelId().equals( problem.getModelId() ) )  )
                     {
                         log.warn( "The artifact's parent POM file '" + file + "' cannot be resolved. " +
                                       "Using defaults for project version metadata.." );
@@ -257,7 +264,9 @@ public class Maven2RepositoryStorage
                         metadata.addFacet( facet );
 
                         String errMsg =
-                            "Error in resolving artifact's parent POM file. " + problem.getException().getMessage();
+                            "Error in resolving artifact's parent POM file. " + ( problem.getException() == null
+                                ? problem.getMessage()
+                                : problem.getException().getMessage() );
                         RepositoryProblemFacet repoProblemFacet = new RepositoryProblemFacet();
                         repoProblemFacet.setRepositoryId( repoId );
                         repoProblemFacet.setId( repoId );