private static String inheritedGroupId( final ModelBuildingResult result, final int modelIndex ) { String groupId = null; final String modelId = result.getModelIds().get( modelIndex ); if ( !modelId.isEmpty() ) { final Model model = result.getRawModel( modelId ); groupId = model.getGroupId() != null ? model.getGroupId() : inheritedGroupId( result, modelIndex + 1 ); } return groupId; }
/** * @return the model id as <code>groupId:artifactId:packaging:version</code> */ public String getId() { StringBuilder id = new StringBuilder( 64 ); id.append( ( getGroupId() == null ) ? "[inherited]" : getGroupId() ); id.append( ":" ); id.append( getArtifactId() ); id.append( ":" ); id.append( getPackaging() ); id.append( ":" ); id.append( ( getVersion() == null ) ? "[inherited]" : getVersion() ); return id.toString(); }
protected void mergeModel_GroupId( Model target, Model source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getGroupId(); if ( src != null ) { if ( sourceDominant || target.getGroupId() == null ) { target.setGroupId( src ); target.setLocation( "groupId", source.getLocation( "groupId" ) ); } } }
private static String getKey( Model model ) { return "project>" + model.getGroupId() + ":" + model.getArtifactId() + ":" + model.getVersion(); }
private void validateEffectiveModelAgainstDependency( String prefix, ModelProblemCollector problems, Model m, Dependency d, ModelBuildingRequest request ) { String key = d.getGroupId() + ":" + d.getArtifactId() + ":" + d.getVersion() + ( d.getClassifier() != null ? ":" + d.getClassifier() : "" ); String mKey = m.getGroupId() + ":" + m.getArtifactId() + ":" + m.getVersion(); if ( key.equals( mKey ) ) { // This means a module which is build has a dependency which has the same // groupId, artifactId, version and classifier coordinates. This is in consequence // a self reference or in other words a circular reference which can not being resolved. addViolation( problems, Severity.FATAL, Version.V31, prefix + " " + key, key, "is referencing itself.", d ); } }
projVersionStr = model.getParent().getVersion(); String projectName = model.getGroupId() + ":" + model.getArtifactId(); assertNotNull("Unable to resolve project version for " + projectName, projVersionStr ); } catch( FileNotFoundException fnfe ) {
private void validate20RawDependenciesSelfReferencing( ModelProblemCollector problems, Model m, List<Dependency> dependencies, String prefix, ModelBuildingRequest request ) { // We only check for groupId/artifactId/version/classifier cause if there is another // module with the same groupId/artifactId/version/classifier this will fail the build // earlier like "Project '...' is duplicated in the reactor. // So it is sufficient to check only groupId/artifactId/version/classifier and not the // packaging type. for ( Dependency dependency : dependencies ) { String key = dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion() + ( dependency.getClassifier() != null ? ":" + dependency.getClassifier() : "" ); String mKey = m.getGroupId() + ":" + m.getArtifactId() + ":" + m.getVersion(); if ( key.equals( mKey ) ) { // This means a module which is build has a dependency which has the same // groupId, artifactId, version and classifier coordinates. This is in consequence // a self reference or in other words a circular reference which can not being resolved. addViolation( problems, Severity.FATAL, Version.V31, prefix + " " + key, key, "is referencing itself.", dependency ); } } }
private List injectActiveProfiles( ProfileManager profileManager, Model model ) throws ProjectBuildingException { List activeProfiles; if ( profileManager != null ) { try { activeProfiles = profileManager.getActiveProfiles(); } catch ( ProfileActivationException e ) { String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() ); throw new ProjectBuildingException( projectId, e.getMessage(), e ); } for ( Iterator it = activeProfiles.iterator(); it.hasNext(); ) { Profile profile = (Profile) it.next(); profileInjector.inject( profile, model ); } } else { activeProfiles = Collections.EMPTY_LIST; } return activeProfiles; }
public String getGroupId() { String groupId = getModel().getGroupId(); if ( ( groupId == null ) && ( getModel().getParent() != null ) ) { groupId = getModel().getParent().getGroupId(); } return groupId; }
private void populateReactorModelPool( ReactorModelPool reactorModelPool, List<InterimResult> interimResults ) { for ( InterimResult interimResult : interimResults ) { Model model = interimResult.result.getEffectiveModel(); reactorModelPool.put( model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPomFile() ); populateReactorModelPool( reactorModelPool, interimResult.modules ); } }
public String getGroupId() { String groupId = getModel().getGroupId(); if ( ( groupId == null ) && ( getModel().getParent() != null ) ) { groupId = getModel().getParent().getGroupId(); } return groupId; }
private List buildArtifactRepositories( Model model ) throws ProjectBuildingException { try { return ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container ); } catch ( InvalidRepositoryException e ) { String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() ); throw new ProjectBuildingException( projectId, e.getMessage(), e ); } }
static String toId( Model model ) { if ( model == null ) { return ""; } String groupId = model.getGroupId(); if ( groupId == null && model.getParent() != null ) { groupId = model.getParent().getGroupId(); } String artifactId = model.getArtifactId(); String version = model.getVersion(); if ( version == null ) { version = "[unknown-version]"; } return toId( groupId, artifactId, version ); }
validateId( "groupId", result, model.getGroupId() ); if ( parent != null ) if ( parent.getGroupId().equals( model.getGroupId() ) && parent.getArtifactId().equals( model.getArtifactId() ) )
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
if ( child.getGroupId() == null ) child.setGroupId( parent.getGroupId() );
if ( child.getGroupId() == null ) child.setGroupId( parent.getGroupId() );
validateId( "groupId", problems, m.getGroupId(), m );
parent ); if ( equals( parent.getGroupId(), m.getGroupId() ) && equals( parent.getArtifactId(), m.getArtifactId() ) ) "4.0.0" ); validateStringNoExpression( "groupId", problems, Severity.WARNING, Version.V20, m.getGroupId(), m ); if ( parent == null ) validateStringNotEmpty( "groupId", problems, Severity.FATAL, Version.V20, m.getGroupId(), m );
result.setDevelopers( cloneList( src.getDevelopers(), DEVELOPER_CLONER ) ); result.setGroupId( src.getGroupId() ); result.setInceptionYear( src.getInceptionYear() ); result.setIssueManagement( cloneIssueManagement( src.getIssueManagement() ) );