Refine search
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 ); }
if ( StringUtils.isEmpty( parentModel.getGroupId() ) ) else if ( StringUtils.isEmpty( parentModel.getArtifactId() ) ) else if ( parentModel.getGroupId().equals( model.getGroupId() ) && parentModel.getArtifactId().equals( model.getArtifactId() ) ) else if ( StringUtils.isEmpty( parentModel.getVersion() ) ) createCacheKey( parentModel.getGroupId(), parentModel.getArtifactId(), parentModel.getVersion() ); MavenProject parentProject = (MavenProject) rawProjectCache.get( parentKey ); String parentRelativePath = parentModel.getRelativePath(); getLogger().debug( "Searching for parent-POM: " + parentModel.getId() + " of project: " + getLogger().debug( "Parent-POM: " + parentModel.getId() + " for project: " + candidateParentGroupId = candidateParent.getParent().getGroupId(); candidateParentVersion = candidateParent.getParent().getVersion(); if ( parentModel.getGroupId().equals( candidateParentGroupId ) && parentModel.getArtifactId().equals( candidateParent.getArtifactId() ) && parentModel.getVersion().equals( candidateParentVersion ) ) parentModel.getRelativePath() + "\' for project: " + project.getId() ); parentModel.getRelativePath() + "' in parent specification in " + project.getId() + ":" +
public static Parent cloneParent( Parent src ) { if ( src == null ) { return null; } Parent result = new Parent(); result.setArtifactId( src.getArtifactId() ); result.setGroupId( src.getGroupId() ); result.setRelativePath( src.getRelativePath() ); result.setVersion( src.getVersion() ); return result; }
protected void mergeParent_ArtifactId( Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getArtifactId(); if ( src != null ) { if ( sourceDominant || target.getArtifactId() == null ) { target.setArtifactId( src ); target.setLocation( "artifactId", source.getLocation( "artifactId" ) ); } } }
protected void mergeParent_Version( Parent target, Parent 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" ) ); } } }
if ( child.getGroupId() == null ) child.setGroupId( parent.getGroupId() ); if ( child.getParent() != null ) child.setVersion( child.getParent().getVersion() );
final String FILE_SEP = System.getProperty("file.separator"); String pathToModelPackage = "src" + FILE_SEP + "main" + FILE_SEP + "java" + FILE_SEP; if (getProject().getPackaging().equals("war") && (getProject().hasParent() && !getProject().getParentArtifact().getGroupId().contains("appfuse"))) { String moduleName = (String) getProject().getParent().getModules().get(0); String pathToParent = getProject().getOriginalModel().getParent().getRelativePath(); pathToParent = pathToParent.substring(0, pathToParent.lastIndexOf('/') + 1); pathToParent = pathToParent.replaceAll("/", FILE_SEP);
throw new DuplicateProjectException( projectId, conflictingProject.getFile(), project.getFile(), "Project '" + projectId + "' is duplicated in the reactor" ); String projectKey = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); Parent parent = project.getModel().getParent(); addEdge( projectMap, vertexMap, null, projectVertex, parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), true, false );
private List<String> alterModel(MavenProject project, String newVersion) { Model originalModel = project.getOriginalModel(); originalModel.setVersion(newVersion); String searchingFrom = project.getArtifactId(); MavenProject parent = project.getParent(); if (parent != null && isSnapshot(parent.getVersion())) { try { ReleasableModule parentBeingReleased = reactor.find(parent.getGroupId(), parent.getArtifactId(), parent.getVersion()); originalModel.getParent().setVersion(parentBeingReleased.getVersionToDependOn()); log.debug(" Parent " + parentBeingReleased.getArtifactId() + " rewritten to version " + parentBeingReleased.getVersionToDependOn()); } catch (UnresolvedSnapshotDependencyException e) { Properties projectProperties = project.getProperties(); for (Dependency dependency : originalModel.getDependencies()) { String version = dependency.getVersion(); if (isSnapshot(resolveVersion(version, projectProperties))) {
try { Model model = new MavenXpp3Reader().read(contentStream); MavenProject project = new MavenProject(model); ((ExtendedDocument) artifact).setExtendedType(JavaModel.TYPE_MAVEN_POM_XML); for (String key :project.getProperties().stringPropertyNames()) { String value = project.getProperties().getProperty(key); SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_PROPERTY + key, value); if (artifact.getVersion()==null) artifact.setVersion(project.getVersion()); SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_ARTIFACT_ID, model.getArtifactId()); SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_GROUP_ID, model.getGroupId()); SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_VERSION, model.getVersion()); SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_PACKAGING, model.getPackaging()); if (model.getParent()!=null) { SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_PARENT_ARTIFACT_ID, model.getParent().getArtifactId()); SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_PARENT_GROUP_ID, model.getParent().getGroupId()); SrampModelUtils.setCustomProperty(artifact, JavaModel.PROP_MAVEN_PARENT_VERSION, model.getParent().getVersion());
/** * Method writeParent. * * @param parent * @param serializer * @param tagName * @throws java.io.IOException */ private void writeParent( Parent parent, String tagName, XmlSerializer serializer ) throws java.io.IOException { serializer.startTag( NAMESPACE, tagName ); if ( parent.getGroupId() != null ) { serializer.startTag( NAMESPACE, "groupId" ).text( parent.getGroupId() ).endTag( NAMESPACE, "groupId" ); } if ( parent.getArtifactId() != null ) { serializer.startTag( NAMESPACE, "artifactId" ).text( parent.getArtifactId() ).endTag( NAMESPACE, "artifactId" ); } if ( parent.getVersion() != null ) { serializer.startTag( NAMESPACE, "version" ).text( parent.getVersion() ).endTag( NAMESPACE, "version" ); } if ( ( parent.getRelativePath() != null ) && !parent.getRelativePath().equals( "../pom.xml" ) ) { serializer.startTag( NAMESPACE, "relativePath" ).text( parent.getRelativePath() ).endTag( NAMESPACE, "relativePath" ); } serializer.endTag( NAMESPACE, tagName ); } //-- void writeParent( Parent, String, XmlSerializer )
validateStringNotEmpty( "modelVersion", result, model.getModelVersion() ); validateId( "groupId", result, model.getGroupId() ); validateId( "artifactId", result, model.getArtifactId() ); validateStringNotEmpty( "packaging", result, model.getPackaging() ); if ( parent != null ) if ( parent.getGroupId().equals( model.getGroupId() ) && parent.getArtifactId().equals( model.getArtifactId() ) )
@Override public void validateRawModel( Model m, ModelBuildingRequest request, ModelProblemCollector problems ) Parent parent = m.getParent(); if ( parent != null ) validateStringNotEmpty( "parent.groupId", problems, Severity.FATAL, Version.BASE, parent.getGroupId(), parent ); validateStringNotEmpty( "parent.artifactId", problems, Severity.FATAL, Version.BASE, parent.getArtifactId(), parent ); validateStringNotEmpty( "parent.version", problems, Severity.FATAL, Version.BASE, parent.getVersion(), parent ); if ( equals( parent.getGroupId(), m.getGroupId() ) && equals( parent.getArtifactId(), m.getArtifactId() ) ) if ( equals( "LATEST", parent.getVersion() ) || equals( "RELEASE", parent.getVersion() ) )
public void addParent(File pom, File parentPom) throws IOException, XmlPullParserException { Model generatedModel=readPom(pom); if (null != generatedModel.getParent()) { log.info("Parent element not overwritten in " + pom); return; } Model parentModel=readPom(parentPom); Parent parent=new Parent(); parent.setGroupId(parentModel.getGroupId()); if (parent.getGroupId() == null) { parent.setGroupId(parentModel.getParent().getGroupId()); } parent.setArtifactId(parentModel.getArtifactId()); parent.setVersion(parentModel.getVersion()); if (parent.getVersion() == null) { parent.setVersion(parentModel.getParent().getVersion()); } generatedModel.setParent(parent); writePom(generatedModel, pom, pom); }
private String rewriteParent( MavenProject project, Model targetModel, ReleaseDescriptor releaseDescriptor, boolean simulate ) throws ReleaseFailureException { String parentVersion = null; if ( project.hasParent() ) { MavenProject parent = project.getParent(); String key = ArtifactUtils.versionlessKey( parent.getGroupId(), parent.getArtifactId() ); parentVersion = getNextVersion( releaseDescriptor, key ); if ( parentVersion == null ) { //MRELEASE-317 parentVersion = getResolvedSnapshotVersion( key, releaseDescriptor ); } if ( parentVersion == null ) { String original = getOriginalVersion( releaseDescriptor, key, simulate ); if ( parent.getVersion().equals( original ) ) { throw new ReleaseFailureException( "Version for parent '" + parent.getName() + "' was not mapped" ); } } else { targetModel.getParent().setVersion( parentVersion ); } } return parentVersion; }
public static boolean hasBadParentDefinition(MavenProject parent, String module) throws IOException, XmlPullParserException { Model moduleModel = POMManager.getModelOfModule(parent, module); if (moduleModel != null && moduleModel.getParent() == null) return false; // no parent so can't be bad return (moduleModel != null && parent.getGroupId().equals(moduleModel.getParent().getGroupId()) && parent.getArtifactId().equals(moduleModel.getParent().getArtifactId()) && parent.getVersion().equals(moduleModel.getParent().getVersion()) ); }
/** * @param parent * @param title * @param mp * @param p * @return */ public static MavenRepositorySearchDialog createSearchParentDialog(Shell parent, String title, MavenProject mp, IProject p) { Set<ArtifactKey> artifacts = new HashSet<ArtifactKey>(); Map<ArtifactKey, String> managed = new HashMap<ArtifactKey, String>(); if(mp != null && mp.getModel().getParent() != null) { Parent par = mp.getModel().getParent(); artifacts.add(new ArtifactKey(par.getGroupId(), par.getArtifactId(), par.getVersion(), null)); } return new MavenRepositorySearchDialog(parent, title, IIndex.SEARCH_PARENTS, artifacts, managed, false, mp, p, true); }
throws ModelBuildingException resolver.resolveRawModel( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() ); .setMessage( e.getMessage().toString() ).setLocation( parent.getLocation( "" ) ).setException( e ) ); throw problems.newModelBuildingException(); candidateSource = new FileModelSource( candidateModel.getPomFile() ); groupId = candidateModel.getParent().getGroupId(); String artifactId = candidateModel.getArtifactId(); version = candidateModel.getParent().getVersion(); if ( groupId == null || !groupId.equals( parent.getGroupId() ) || artifactId == null || !artifactId.equals( parent.getArtifactId() ) ) buffer.append( " instead of " ).append( parent.getGroupId() ).append( ':' ); buffer.append( parent.getArtifactId() ).append( ", please verify your project structure" ); .setMessage( buffer.toString() ).setLocation( parent.getLocation( "" ) ) ); return null; if ( version != null && parent.getVersion() != null && !version.equals( parent.getVersion() ) ) VersionRange parentRange = VersionRange.createFromVersionSpec( parent.getVersion() ); if ( !parentRange.hasRestrictions() )
if (model.getVersion() != null) { return model.getVersion(); } else if (model.getParent() != null) { return model.getParent().getVersion(); return model.getGroupId(); } else if (model.getParent() != null) { return model.getParent().getGroupId(); return model.getArtifactId(); } else if (model.getParent() != null) { return model.getParent().getArtifactId();
public String getVersion() { String version = getModel().getVersion(); if ( ( version == null ) && ( getModel().getParent() != null ) ) { version = getModel().getParent().getVersion(); } return version; }