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

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

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

Parent.getRelativePath介绍

[英]Get the relative path of the parent pom.xml file within the check out. If not specified, it defaults to ../pom.xml. Maven looks for the parent POM first in this location on the filesystem, then the local repository, and lastly in the remote repo. relativePath allows you to select a different location, for example when your structure is flat, or deeper without an intermediate parent POM. However, the group ID, artifact ID and version are still required, and must match the file in the location given or it will revert to the repository for the POM. This feature is only for enhancing the development in a local checkout of that project. Set the value to an empty string in case you want to disable the feature and always resolve the parent POM from the repositories.
[中]获取签出中父pom.xml文件的相对路径。如果未指定,则默认为[$1$]。Maven首先在文件系统的这个位置查找父POM,然后在本地存储库中查找,最后在远程repo中查找。relativePath允许你选择一个不同的位置,例如当你的结构是平坦的,或者在没有中间父POM的情况下更深。但是,仍然需要组ID、工件ID和版本,并且必须与给定位置的文件匹配,否则它将恢复到POM的存储库。此功能仅用于增强该项目的本地签出中的开发。如果要禁用该功能并始终从存储库解析父POM,请将该值设置为空字符串。

代码示例

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

protected void mergeParent_RelativePath( Parent target, Parent source, boolean sourceDominant,
                     Map<Object, Object> context )
{
  String src = source.getRelativePath();
  if ( src != null )
  {
    if ( sourceDominant || target.getRelativePath() == null )
    {
      target.setRelativePath( src );
      target.setLocation( "relativePath", source.getLocation( "relativePath" ) );
    }
  }
}

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

private ModelSource getParentPomFile( Model childModel, ModelSource source )
{
  if ( !( source instanceof ModelSource2 ) )
  {
    return null;
  }
  String parentPath = childModel.getParent().getRelativePath();
  if ( parentPath == null || parentPath.length() <= 0 )
  {
    return null;
  }
  return ( (ModelSource2) source ).getRelatedSource( parentPath );
}

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

/**
 * 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: apache/maven

if ( childModel.getProjectDirectory() != null )
  if ( parent.getRelativePath() == null || parent.getRelativePath().length() <= 0 )

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

String parentRelativePath = parentModel.getRelativePath();
        parentModel.getRelativePath() + "\' for project: " + project.getId() );
        parentModel.getRelativePath() + "' in parent specification in " + project.getId() + ":" +
        "\n  Specified: " + parentModel.getId() + "\n  Found:     " + candidateParent.getId() );

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

private void writeParent() throws IOException {
  Parent parent = model.getParent();
  if (parent != null) {
    out.write("        parent(" + br);
    out.write("            groupId -> \"" + parent.getGroupId() + "\"," + br);
    out.write("            artifactId -> \"" + parent.getArtifactId() + "\"");
    if (parent.getVersion() != null) {
      out.write("," + br);
      out.write("            version -> \"" + parent.getVersion()+ "\"");
    }
    if (parent.getRelativePath() != null) {
      out.write("," + br);
      out.write("            relativePath -> \"" + parent.getRelativePath()+ "\"" + br);
    }
    out.write("        );" + br);
  }
  
  writeProperties();
}

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

void parent(Parent parent) {
  if (parent != null) {
    p.print("inherit", parent.getGroupId() + ":"
        + parent.getArtifactId() + ":" + parent.getVersion());
    if (parent.getRelativePath() != null ) {
      if ( parent.getRelativePath().equals( "../pom.xml" ) ) {
        //p.append( ", '" ).append( "../pom.rb" ).append( "'" );
        p.println();
      }
      else {
        p.append(", '" + parent.getRelativePath() + "'").println();
      }
    }
    else {
      p.println();
    }
  }
}

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

private void parent(PrintWriter pw, Model model) {
  if (model.getParent() != null) {
   pw.print(indent + "inherits: " + model.getParent().getGroupId() + ":" + model.getParent().getArtifactId() + ":" + model.getParent().getVersion());
   if (model.getParent().getRelativePath() != null) {
    //pw.println(":" + model.getParent().getRelativePath());
//        pw.println(":" + "../pom.atom");
   }
   pw.println();
  }
 }

代码示例来源:origin: takari/polyglot-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.attribute( NAMESPACE, "groupId", parent.getGroupId() );
  }
  if ( parent.getArtifactId() != null )
  {
    serializer.attribute( NAMESPACE, "artifactId", parent.getArtifactId() );
  }
  if ( parent.getVersion() != null )
  {
    serializer.attribute( NAMESPACE, "version", parent.getVersion() );
  }
  if ( ( parent.getRelativePath() != null ) && !parent.getRelativePath().equals( "../pom.xml" ) )
  {
    serializer.attribute( NAMESPACE, "relativePath", parent.getRelativePath() );
  }
  serializer.endTag( NAMESPACE, tagName );
} //-- void writeParent( Parent, String, XmlSerializer )

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

private boolean belongsToMultiModuleProject(File pom) throws Exception {
  Model model = reader.read(new FileInputStream(pom));
  Parent parent = model.getParent();
  if (parent != null) {
   return new File(pom.getParentFile(), parent.getRelativePath()).exists();
  }
  return false;
 }
}

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

protected void mergeParent_RelativePath( Parent target, Parent source, boolean sourceDominant,
                     Map<Object, Object> context )
{
  String src = source.getRelativePath();
  if ( src != null )
  {
    if ( sourceDominant || target.getRelativePath() == null )
    {
      target.setRelativePath( src );
      target.setLocation( "relativePath", source.getLocation( "relativePath" ) );
    }
  }
}

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

private ModelSource getParentPomFile( Model childModel, ModelSource source )
{
  if ( !( source instanceof ModelSource2 ) )
  {
    return null;
  }
  String parentPath = childModel.getParent().getRelativePath();
  if ( parentPath == null || parentPath.length() <= 0 )
  {
    return null;
  }
  return ( (ModelSource2) source ).getRelatedSource( parentPath );
}

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

void parent(Parent parent) {
  if (parent != null) {
    p.print("inherit", parent.getGroupId() + ":"
        + parent.getArtifactId() + ":" + parent.getVersion());
    if (parent.getRelativePath() != null ) {
      if ( parent.getRelativePath().equals( "../pom.xml" ) ) {
        //p.append( ", '" ).append( "../pom.rb" ).append( "'" );
        p.println();
      }
      else {
        p.append(", '" + parent.getRelativePath() + "'").println();
      }
    }
    else {
      p.println();
    }
  }
}

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

void parent(Parent parent) {
  if (parent != null) {
    p.print("inherit", parent.getGroupId() + ":"
        + parent.getArtifactId() + ":" + parent.getVersion());
    if (parent.getRelativePath() != null ) {
      if ( parent.getRelativePath().equals( "../pom.xml" ) ) {
        //p.append( ", '" ).append( "../pom.rb" ).append( "'" );
        p.println();
      }
      else {
        p.append(", '" + parent.getRelativePath() + "'").println();
      }
    }
    else {
      p.println();
    }
  }
}

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

private void parent(PrintWriter pw, Model model) {
  if (model.getParent() != null) {
   pw.print(indent + "inherits: " + model.getParent().getGroupId() + ":" + model.getParent().getArtifactId() + ":" + model.getParent().getVersion());
   if (model.getParent().getRelativePath() != null) {
    //pw.println(":" + model.getParent().getRelativePath());
//        pw.println(":" + "../pom.atom");
   }
   pw.println();
  }
 }

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

private void parent(PrintWriter pw, Model model) {
  if (model.getParent() != null) {
   pw.print(indent + "inherits: " + model.getParent().getGroupId() + ":" + model.getParent().getArtifactId() + ":" + model.getParent().getVersion());
   if (model.getParent().getRelativePath() != null) {
    //pw.println(":" + model.getParent().getRelativePath());
//        pw.println(":" + "../pom.atom");
   }
   pw.println();
  }
 }

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-maven-embedder

/**
 * Method updateParent.
 * 
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
protected void updateParent(Parent value, String xmlTag, Counter counter, Element element)
{
  boolean shouldExist = value != null;
  Element root = updateElement(counter, element, xmlTag, shouldExist);
  if (shouldExist) {
    Counter innerCount = new Counter(counter.getDepth() + 1);
    findAndReplaceSimpleElement(innerCount, root,  "artifactId", value.getArtifactId(), null);
    findAndReplaceSimpleElement(innerCount, root,  "groupId", value.getGroupId(), null);
    findAndReplaceSimpleElement(innerCount, root,  "version", value.getVersion(), null);
    findAndReplaceSimpleElement(innerCount, root,  "relativePath", value.getRelativePath(), "../pom.xml");
  }
} //-- void updateParent(Parent, String, Counter, Element)

代码示例来源:origin: org.codehaus.mevenide/nb-mvn-embedder

/**
 * Method updateParent
 * 
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
protected void updateParent(Parent value, String xmlTag, Counter counter, Element element)
{
  boolean shouldExist = value != null;
  Element root = updateElement(counter, element, xmlTag, shouldExist);
  if (shouldExist) {
    Counter innerCount = new Counter(counter.getDepth() + 1);
    findAndReplaceSimpleElement(innerCount, root,  "artifactId", value.getArtifactId(), null);
    findAndReplaceSimpleElement(innerCount, root,  "groupId", value.getGroupId(), null);
    findAndReplaceSimpleElement(innerCount, root,  "version", value.getVersion(), null);
    findAndReplaceSimpleElement(innerCount, root,  "relativePath", value.getRelativePath(), "../pom.xml");
  }
} //-- void updateParent(Parent, String, Counter, Element)

代码示例来源:origin: org.jboss.forge.addon/maven-impl

/**
* Method updateParent.
*
* @param value
* @param element
* @param counter
* @param xmlTag
*/
protected void updateParent(Parent value, String xmlTag, Counter counter, Element element)
{
 boolean shouldExist = value != null;
 Element root = updateElement(counter, element, xmlTag, shouldExist);
 if (shouldExist)
 {
   Counter innerCount = new Counter(counter.getDepth() + 1);
   findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null);
   findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), null);
   findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null);
   findAndReplaceSimpleElement(innerCount, root, "relativePath", value.getRelativePath(), "../pom.xml");
 }
} // -- void updateParent(Parent, String, Counter, Element)

相关文章