From 57b5334aef407b28c8c58c3306968a5fd9206a58 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 25 Feb 2012 20:45:18 +0000 Subject: [PATCH] avoid failing on java profile or other profiles by using a TwoPhaseBuiling maven build model request git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1293680 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven2/Maven2RepositoryStorage.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java index b1a1f78ce..503a52b76 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java @@ -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 ); -- 2.39.5