org.apache.maven.model.Parent.setArtifactId()方法的使用及代码示例

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

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

Parent.setArtifactId介绍

[英]Set the artifact id of the parent project to inherit from.
[中]设置要从中继承的父项目的工件id。

代码示例

代码示例来源: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: 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

parent.setArtifactId( interpolatedTrimmed( parser.nextText(), "artifactId" ) );

代码示例来源:origin: takari/polyglot-maven

public Parent mergeParent(Parent parent) {
  parent.setGroupId(groupId);
  parent.setArtifactId(artifactId);
  if(version != null) parent.setVersion(version);
  return parent;
 }
}

代码示例来源:origin: takari/polyglot-maven

public static Parent parse(final Object value) {
  assert value != null;

  if (value instanceof String) {
   Parent node = new Parent();
   String[] items = ((String) value).split(":");
   switch (items.length) {
   case 3:
    node.setGroupId(items[0]);
    node.setArtifactId(items[1]);
    node.setVersion(items[2]);
    return node;
   }
  }

  return null;
 }
}

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

parent.setArtifactId( interpolatedTrimmed( parser.nextText(), "artifactId" ) );

代码示例来源:origin: takari/polyglot-maven

parent.setArtifactId( getTrimmedValue( value ) );

代码示例来源:origin: takari/polyglot-maven

private Parent parent() {
 if (match(Kind.PARENT) == null)
  return null;
 if (match(Kind.COLON) == null) {
  log.severe("Expected ':' after 'inherits'");
  return null;
 }
 Id parentId = id(true);
 if (parentId == null) {
  log.severe("Expected complete artifact identifier in 'parent' clause");
  return null;
 }
 String relativePath = "../pom.atom";
 if (match(Token.Kind.COLON) != null) {
  relativePath = relativePath();
  if (relativePath == null) {
   return null;
  }
 }
 Parent parent = new Parent();
 parent.setGroupId(parentId.getGroup());
 parent.setArtifactId(parentId.getArtifact());
 parent.setVersion(parentId.getVersion());
 parent.setRelativePath(relativePath);
 return parent;
}

代码示例来源:origin: io.takari.polyglot/polyglot-yaml

public Parent mergeParent(Parent parent) {
  parent.setGroupId(groupId);
  parent.setArtifactId(artifactId);
  if(version != null) parent.setVersion(version);
  return parent;
 }
}

代码示例来源:origin: io.takari.polyglot/polyglot-groovy

public static Parent parse(final Object value) {
  assert value != null;

  if (value instanceof String) {
   Parent node = new Parent();
   String[] items = ((String) value).split(":");
   switch (items.length) {
   case 3:
    node.setGroupId(items[0]);
    node.setArtifactId(items[1]);
    node.setVersion(items[2]);
    return node;
   }
  }

  return null;
 }
}

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

/** Updates a Maven model. */
public void updateModel(Model model) {
 String groupId = parentGroupIdCombo.getText().trim();
 if(groupId.length() > 0) {
  Parent parent = new Parent();
  parent.setGroupId(groupId);
  parent.setArtifactId(parentArtifactIdCombo.getText().trim());
  parent.setVersion(parentVersionCombo.getText().trim());
  model.setParent(parent);
 }
}

代码示例来源:origin: io.tesla.maven/maven-model

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: stackoverflow.com

Parent p = new Parent();
p.setGroupId("org.codehaus.griffon");
p.setArtifactId("application-master-pom");
p.setVersion("1.0.0");
MavenFacet mavenFacet = getFaceted().getFacet(MavenFacet.class);
Model model = mavenFacet.getModel();
model.setParent(p);
mavenFacet.setModel(model);

代码示例来源:origin: io.tesla.polyglot/tesla-polyglot-atom

private Parent parent() {
 if (match(Kind.PARENT) == null)
  return null;
 if (match(Kind.COLON) == null) {
  log.severe("Expected ':' after 'inherits'");
  return null;
 }
 Id parentId = id(true);
 if (parentId == null) {
  log.severe("Expected complete artifact identifier in 'parent' clause");
  return null;
 }
 String relativePath = "../pom.atom";
 if (match(Token.Kind.COLON) != null) {
  relativePath = relativePath();
  if (relativePath == null) {
   return null;
  }
 }
 Parent parent = new Parent();
 parent.setGroupId(parentId.getGroup());
 parent.setArtifactId(parentId.getArtifact());
 parent.setVersion(parentId.getVersion());
 parent.setRelativePath(relativePath);
 return parent;
}

代码示例来源:origin: kiegroup/appformer

private Parent getParent(final POM pom) {
  if (pom.getParent() == null) {
    return null;
  } else {
    Parent parent = new Parent();
    parent.setGroupId(pom.getParent().getGroupId());
    parent.setArtifactId(pom.getParent().getArtifactId());
    parent.setVersion(pom.getParent().getVersion());
    return parent;
  }
}

代码示例来源:origin: org.uberfire/uberfire-project-backend

private Parent getParent(final POM pom) {
  if (pom.getParent() == null) {
    return null;
  } else {
    Parent parent = new Parent();
    parent.setGroupId(pom.getParent().getGroupId());
    parent.setArtifactId(pom.getParent().getArtifactId());
    parent.setVersion(pom.getParent().getVersion());
    return parent;
  }
}

代码示例来源:origin: org.guvnor/guvnor-project-backend

private Parent getParent(final POM pom) {
  if (pom.getParent() == null) {
    return null;
  } else {
    Parent parent = new Parent();
    parent.setGroupId(pom.getParent().getGroupId());
    parent.setArtifactId(pom.getParent().getArtifactId());
    parent.setVersion(pom.getParent().getVersion());
    return parent;
  }
}

代码示例来源:origin: Adobe-Marketing-Cloud/aem-eclipse-developer-tools

private void fixParentProject(IProject p, IProject parentProject)
    throws CoreException {
  IFile existingPom = p.getFile("pom.xml");
  Model model = MavenPlugin.getMavenModelManager().readMavenModel(existingPom);
  Model parent = MavenPlugin.getMavenModelManager().readMavenModel(parentProject.getFile("pom.xml"));
  //Parent oldParent = model.getParent();
  Parent newParent = new Parent();
  newParent.setGroupId(parent.getGroupId());
  newParent.setArtifactId(parent.getArtifactId());
  newParent.setRelativePath(calculateRelativePath(p, parentProject));
  newParent.setVersion(parent.getVersion());
  model.setParent(newParent);
  // outright deletion doesn't work on windows as the process has a ref to the file itself
  // so creating a temp '_newpom_.xml'
  final IFile newPom = p.getFile("_newpom_.xml");
  MavenPlugin.getMavenModelManager().createMavenModel(newPom, model);
  // then copying that content over to the pom.xml
  existingPom.setContents(newPom.getContents(), true,  true, new NullProgressMonitor());
  // and deleting the temp pom
  newPom.delete(true,  false, new NullProgressMonitor());
  
}

代码示例来源:origin: org.onehippo.cms7.essentials/hippo-essentials-plugin-api-implementation

public static boolean upgradeToEnterpriseProject() {
  if (isEnterpriseProject()) {
    return true;
  }
  final Repository repository = new RepositoryRestful();
  repository.setId("hippo-maven2-enterprise");
  repository.setId("Hippo Enterprise Maven 2");
  repository.setId("https://maven.onehippo.com/maven2-enterprise");
  addRepository(repository);
  final Model pomModel = ProjectUtils.getPomModel(TargetPom.PROJECT);
  if (pomModel != null) {
    final Parent parent = new Parent();
    parent.setArtifactId(ProjectUtils.ENT_GROUP_ID);
    parent.setGroupId(ProjectUtils.ENT_GROUP_ID);
    pomModel.setParent(parent);
    // add indicator:
    final Model cmsModel = ProjectUtils.getPomModel(TargetPom.CMS);
    final Dependency indicator = new Dependency();
    indicator.setArtifactId("hippo-addon-edition-indicator");
    indicator.setGroupId("com.onehippo.cms7");
    cmsModel.addDependency(indicator);
    writePom(ProjectUtils.getPomPath(TargetPom.CMS), cmsModel);
    return writePom(ProjectUtils.getPomPath(TargetPom.PROJECT), pomModel);
  }
  return false;
}

代码示例来源: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);
}

相关文章