private Model getSuperModel() throws ProjectBuildingException { URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MAVEN_MODEL_VERSION + ".xml" ); String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID ); return readModel( projectId, url, true ); }
private Model readModel( String projectId, URL url, boolean strict ) throws ProjectBuildingException { Reader reader = null; try { reader = ReaderFactory.newXmlReader( url.openStream() ); return readModel( projectId, url.toExternalForm(), reader, strict ); } catch ( IOException e ) { throw new ProjectBuildingException( projectId, "Failed build model from URL \'" + url.toExternalForm() + "\'\nError: \'" + e.getLocalizedMessage() + "\'", e ); } finally { IOUtil.close( reader ); } }
private Model readModel( String projectId, File file, boolean strict ) throws ProjectBuildingException { Reader reader = null; try { reader = ReaderFactory.newXmlReader( file ); return readModel( projectId, file.getAbsolutePath(), reader, strict ); } catch ( FileNotFoundException e ) { throw new ProjectBuildingException( projectId, "Could not find the model file '" + file.getAbsolutePath() + "'.", e ); } catch ( IOException e ) { throw new ProjectBuildingException( projectId, "Failed to build model from file '" + file.getAbsolutePath() + "'.\nError: \'" + e.getLocalizedMessage() + "\'", e ); } finally { IOUtil.close( reader ); } }
private MavenProject buildFromSourceFileInternal( File projectDescriptor, ProjectBuilderConfiguration config, boolean checkDistributionManagementStatus ) throws ProjectBuildingException { Model model = readModel( "unknown", projectDescriptor, true ); MavenProject project = buildInternal( projectDescriptor.getAbsolutePath(), model, config, buildArtifactRepositories( getSuperModel() ), projectDescriptor, true ); if ( checkDistributionManagementStatus ) { if ( ( project.getDistributionManagement() != null ) && ( project.getDistributionManagement().getStatus() != null ) ) { String projectId = safeVersionlessKey( project.getGroupId(), project.getArtifactId() ); throw new ProjectBuildingException( projectId, "Invalid project file: distribution status must not be specified for a project outside of the repository" ); } } return project; }
model = readModel( projectId, file, false );
Model candidateParent = readModel( projectId, parentDescriptor, strict );