private static String inheritedVersion( final ModelBuildingResult result, final int modelIndex ) { String version = null; final String modelId = result.getModelIds().get( modelIndex ); if ( !modelId.isEmpty() ) { final Model model = result.getRawModel( modelId ); version = model.getVersion() != null ? model.getVersion() : inheritedVersion( result, modelIndex + 1 ); } return version; }
/** * @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_Version( Model target, Model source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getVersion(); if ( src != null ) { if ( sourceDominant || target.getVersion() == null ) { target.setVersion( src ); target.setLocation( "version", source.getLocation( "version" ) ); } } }
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 ); } }
MavenXpp3Reader xpp3Reader = new MavenXpp3Reader(); Model model = xpp3Reader.read(reader); projVersionStr = model.getVersion(); if( projVersionStr == null ) { projVersionStr = model.getParent().getVersion();
private static String getPomVersion() { try { MavenXpp3Reader pomReader = new MavenXpp3Reader(); Model model = pomReader .read(new InputStreamReader(new FileInputStream("../pom.xml"), StandardCharsets.UTF_8)); return model.getVersion(); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
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 ); } } }
public String getVersion() { String version = getModel().getVersion(); if ( ( version == null ) && ( getModel().getParent() != null ) ) { version = getModel().getParent().getVersion(); } return version; }
public String getVersion() { String version = getModel().getVersion(); if ( ( version == null ) && ( getModel().getParent() != null ) ) { version = getModel().getParent().getVersion(); } return version; }
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 ); } }
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 ); }
validateStringNotEmpty( "version", result, model.getVersion() );
if ( childModel.getVersion() == null ) if ( childModel.getVersion().contains( "${" ) )
String version = candidateModel.getVersion(); if ( version == null && candidateModel.getParent() != null ) if ( childModel.getVersion() == null ) if ( childModel.getVersion().contains( "${" ) )
validateStringNotEmpty( "version", problems, Severity.ERROR, Version.BASE, m.getVersion(), m ); validateBannedCharacters( "version", problems, errOn31, Version.V20, m.getVersion(), null, m, ILLEGAL_VERSION_CHARS ); validate20ProperSnapshotVersion( "version", problems, errOn31, Version.V20, m.getVersion(), null, m );
if ( child.getVersion() == null )
if ( child.getVersion() == null )
validateStringNotEmpty( "artifactId", problems, Severity.FATAL, Version.V20, m.getArtifactId(), m ); validateVersionNoExpression( "version", problems, Severity.WARNING, Version.V20, m.getVersion(), m ); if ( parent == null ) validateStringNotEmpty( "version", problems, Severity.FATAL, Version.V20, m.getVersion(), m );
result.setVersion( src.getVersion() );