org.apache.maven.model.Parent类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(13.2k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.apache.maven.model.Parent类的一些代码示例,展示了Parent类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parent类的具体详情如下:
包路径:org.apache.maven.model.Parent
类名称:Parent

Parent介绍

[英]The <parent> element contains information required to locate the parent project from which this project will inherit from. Note: The children of this element are not interpolated and must be given as literal values.
[中]<parent>元素包含定位此项目将从中继承的父项目所需的信息。注意:该元素的子元素不是插值的,必须以文字值的形式给出。

代码示例

代码示例来源:origin: apache/maven

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 );
}

代码示例来源:origin: org.apache.maven/maven-project

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() + ":" +

代码示例来源:origin: org.apache.maven/maven-project

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;
}

代码示例来源:origin: apache/maven

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" ) );
    }
  }
}

代码示例来源:origin: apache/maven

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" ) );
    }
  }
}

代码示例来源:origin: org.apache.maven/maven-project

if ( child.getGroupId() == null )
  child.setGroupId( parent.getGroupId() );
  if ( child.getParent() != null )
    child.setVersion( child.getParent().getVersion() );

代码示例来源:origin: appfuse/appfuse

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);

代码示例来源:origin: apache/maven

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 );

代码示例来源:origin: danielflower/multi-module-maven-release-plugin

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))) {

代码示例来源:origin: org.overlord.sramp/s-ramp-integration-java

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());

代码示例来源:origin: apache/maven

/**
 * 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 )

代码示例来源:origin: org.apache.maven/maven-project

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() ) )

代码示例来源:origin: apache/maven

@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() ) )

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

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);
}

代码示例来源:origin: apache/maven-release

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;
}

代码示例来源:origin: io.teecube.tic/tic-bw6

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())
      );
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.m2e.core.ui

/**
 * @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);
}

代码示例来源:origin: apache/maven

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() )

代码示例来源:origin: INRIA/spoon

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();

代码示例来源:origin: org.apache.maven/maven-project

public String getVersion()
{
  String version = getModel().getVersion();
  if ( ( version == null ) && ( getModel().getParent() != null ) )
  {
    version = getModel().getParent().getVersion();
  }
  
  return version;
}

相关文章