當前位置: 首頁>>代碼示例>>Java>>正文


Java Parent類代碼示例

本文整理匯總了Java中org.apache.maven.model.Parent的典型用法代碼示例。如果您正苦於以下問題:Java Parent類的具體用法?Java Parent怎麽用?Java Parent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Parent類屬於org.apache.maven.model包,在下文中一共展示了Parent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeParent

import org.apache.maven.model.Parent; //導入依賴的package包/類
private void writeParent(Parent parent, String tagName, XmlSerializer serializer)
        throws java.io.IOException {
    serializer.startTag(NAMESPACE, tagName);
    flush(serializer);
    StringBuffer b = b(serializer);
    int start = b.length();
    if (parent.getGroupId() != null) {
        writeValue(serializer, "groupId", parent.getGroupId(), parent);
    }
    if (parent.getArtifactId() != null) {
        writeValue(serializer, "artifactId", parent.getArtifactId(), parent);
    }
    if (parent.getVersion() != null) {
        writeValue(serializer, "version", parent.getVersion(), parent);
    }
    if ((parent.getRelativePath() != null) && !parent.getRelativePath().equals("../pom.xml")) {
        writeValue(serializer, "relativePath", parent.getRelativePath(), parent);
    }
    serializer.endTag(NAMESPACE, tagName).flush();
    logLocation(parent, "", start, b.length());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:LocationAwareMavenXpp3Writer.java

示例2: isFunktionParentPom

import org.apache.maven.model.Parent; //導入依賴的package包/類
@Deprecated
public static boolean isFunktionParentPom(Project project) {
    MavenFacet mavenFacet = project.getFacet(MavenFacet.class);
    if (mavenFacet != null) {
        Model model = mavenFacet.getModel();
        if (model != null) {
            Parent parent = model.getParent();
            if (parent != null) {
                String groupId = parent.getGroupId();
                if (groupId != null && groupId.startsWith("io.fabric8.funktion")) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
開發者ID:fabric8io,項目名稱:fabric8-forge,代碼行數:18,代碼來源:SetupProjectHelper.java

示例3: resolveParent

import org.apache.maven.model.Parent; //導入依賴的package包/類
protected ResolvedPom resolveParent(Model model, File pomFile, PomResolveCache cache, PomSource pomSource) throws Exception {
	Parent rawParent = model.getParent();
	if (rawParent != null) {
		if (rawParent.getGroupId() == null || rawParent.getArtifactId() == null || rawParent.getVersion() == null) {
			throw new RuntimeException("Invalid parent for artifact " + createGav(model));
		}
		ResolvedPom parent = cache.getResolvedPom(rawParent.getGroupId(), rawParent.getArtifactId(), rawParent.getVersion());
		if (parent == null) {
			if (pomFile != null && rawParent.getRelativePath() != null) {
				File parentPomFile = new File(pomFile.getParentFile(), rawParent.getRelativePath());
				if (!parentPomFile.isFile()) {
					parentPomFile = new File(parentPomFile, "pom.xml");
				}
				parent = resolvePom(parentPomFile, cache, pomSource);
			} else {
				try (
					InputStream parentIn = pomSource.getPom(rawParent.getGroupId(), rawParent.getArtifactId(), rawParent.getVersion());
				) {
					parent = resolvePom(parentIn, null, cache, pomSource);
				}
			}
		}
		return parent;
	}
	return null;
}
 
開發者ID:uklance,項目名稱:gradle-maven-share,代碼行數:27,代碼來源:PomResolver.java

示例4: resolveModel

import org.apache.maven.model.Parent; //導入依賴的package包/類
@Override
public ModelSource2 resolveModel(final Parent parent) throws UnresolvableModelException {
  final String groupId = parent.getGroupId();
  final String artifactId = parent.getArtifactId();
  final String version = parent.getVersion();
  final ModelSource2 model = resolveModel(groupId, artifactId, version);
  if (nonNull(model)) {
    return model;
  }
  String relativePath = parent.getRelativePath();

  if (nonNull(relativePath) && !relativePath.isEmpty()) {
    File pom = new File(this.projectRoot, relativePath);
    if (!relativePath.endsWith("pom.xml")) {
      pom = new File(relativePath, "pom.xml");
    }
    if (!loaded.contains(pom)) {
      loaded.add(pom);
    }
    if (pom.exists()) {
      return new FileModelSource(pom);
    }
  }
  return null;
}
 
開發者ID:mopemope,項目名稱:meghanada-server,代碼行數:26,代碼來源:POMParser.java

示例5: createModel

import org.apache.maven.model.Parent; //導入依賴的package包/類
private Model createModel(TaskContext taskContext, final Extension extension) {
    final Model model = new Model();
    model.setModelVersion(MODEL_VERSION);
    model.setArtifactId(extension.getName());
    model.setVersion(taskContext.getHybrisVersion().getVersion());
    final Parent parent = new Parent();
    parent.setGroupId(HYBRIS__GROUP_ID);
    parent.setArtifactId(PLATFORM__ARTIFACT_ID);
    parent.setVersion(taskContext.getHybrisVersion().getVersion());
    model.setParent(parent);
    setExtensionPackaging(taskContext, model);
    addExtensionDependencies(taskContext, extension, model);
    addImplicitDependencies(taskContext, extension, model);
    addExternalDependencies(taskContext, extension, model);
    // resolveDependencyVersionConflicts(taskContext, extension, model);
    return model;
}
 
開發者ID:AGETO,項目名稱:hybris-maven-plugin,代碼行數:18,代碼來源:CreatePomFromExtensionTask.java

示例6: setParentVersion

import org.apache.maven.model.Parent; //導入依賴的package包/類
private void setParentVersion(MavenProject project, Document document) {
  Parent parent = project.getModel().getParent();
  if (parent != null) {
    Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata
        .getArtifactCoordinatesByPhase(parent.getGroupId(), parent.getArtifactId());
    ArtifactCoordinates oldCoordinates = coordinatesByPhase.get(ReleasePhase.PRE_RELEASE);
    ArtifactCoordinates newCoordinates = coordinatesByPhase.get(ReleasePhase.RELEASE);

    // null indicates that the parent is not part of the reactor projects since no release version had been calculated
    // for it
    if (newCoordinates != null) {
      this.log.debug("\tUpdate of parent version of module '" + project.getGroupId() + ":" + project.getArtifact()
          + "' [" + oldCoordinates.getVersion() + " => " + newCoordinates.getVersion() + "]");
      PomUtil.setParentVersion(project.getModel(), document, newCoordinates.getVersion());
    }
  }
}
 
開發者ID:shillner,項目名稱:unleash-maven-plugin,代碼行數:18,代碼來源:SetReleaseVersions.java

示例7: setParentVersion

import org.apache.maven.model.Parent; //導入依賴的package包/類
private void setParentVersion(MavenProject project, Document document) {
  Parent parent = project.getModel().getParent();
  if (parent != null) {
    Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata
        .getArtifactCoordinatesByPhase(parent.getGroupId(), parent.getArtifactId());
    ArtifactCoordinates oldCoordinates = coordinatesByPhase.get(ReleasePhase.RELEASE);
    ArtifactCoordinates newCoordinates = coordinatesByPhase.get(ReleasePhase.POST_RELEASE);

    // null indicates that the parent is not part of the reactor projects since no release version had been calculated
    // for it
    if (newCoordinates != null) {
      this.log.debug("\t\tUpdate of parent version of module '" + project.getGroupId() + ":" + project.getArtifact()
          + "' [" + oldCoordinates.getVersion() + " => " + newCoordinates.getVersion() + "]");
      PomUtil.setParentVersion(project.getModel(), document, newCoordinates.getVersion());
    }
  }
}
 
開發者ID:shillner,項目名稱:unleash-maven-plugin,代碼行數:18,代碼來源:SetNextDevVersion.java

示例8: setParentVersion

import org.apache.maven.model.Parent; //導入依賴的package包/類
/**
 * Changes the project's parent version of the POM as well as directly in the XML document preserving the whole
 * document formatting.
 *
 * @param model the POM where to adapt the project's parent version.
 * @param document the POM as an XML document in which the project's parent version shall be adapted.
 * @param newParentVersion the new version to set for the project parent.
 */
public static void setParentVersion(Model model, Document document, String newParentVersion) {
  Preconditions.checkArgument(hasChildNode(document, NODE_NAME_PROJECT),
      "The document doesn't seem to be a POM model, project element is missing.");

  // first step: update parent version of the in-memory model
  Parent parent = model.getParent();
  if (parent != null) {
    parent.setVersion(newParentVersion);
  }

  // second step: update the parent version in the DOM document that will be serialized for later building
  Node parentNode = document.getDocumentElement().getElementsByTagName(PomUtil.NODE_NAME_PARENT).item(0);
  if (parentNode != null) {
    NodeList children = parentNode.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
      Node child = children.item(i);
      if (Objects.equal(child.getNodeName(), PomUtil.NODE_NAME_VERSION)) {
        child.setTextContent(newParentVersion);
      }
    }
  }
}
 
開發者ID:shillner,項目名稱:unleash-maven-plugin,代碼行數:31,代碼來源:PomUtil.java

示例9: getChildModels

import org.apache.maven.model.Parent; //導入依賴的package包/類
/**
 * Returns all the models that have a specified groupId and artifactId as parent.
 *
 * @param reactor The map of models keyed by path.
 * @param groupId The groupId of the parent.
 * @param artifactId The artifactId of the parent.
 * @return a map of models that have a specified groupId and artifactId as parent keyed by path.
 */
public static Map<String, Model> getChildModels( Map<String, Model> reactor, String groupId, String artifactId )
{
    final Map<String, Model> result = new LinkedHashMap<String, Model>();
    for ( Map.Entry<String, Model> entry : reactor.entrySet() )
    {
        final String path = entry.getKey();
        final Model model = entry.getValue();
        final Parent parent = model.getParent();
        if ( parent != null && groupId.equals( parent.getGroupId() )
            && artifactId.equals( parent.getArtifactId() ) )
        {
            result.put( path, model );
        }
    }
    return result;
}
 
開發者ID:mojohaus,項目名稱:versions-maven-plugin,代碼行數:25,代碼來源:PomHelper.java

示例10: populateResult

import org.apache.maven.model.Parent; //導入依賴的package包/類
@Override
public void populateResult(RepositorySystemSession session,
	ArtifactDescriptorResult result,
	Model model) {
	super.populateResult(session, result, model);
	Parent parent = model.getParent();
	if (parent != null) {
		DefaultArtifact art =
			new DefaultArtifact(parent.getGroupId(),
				parent.getArtifactId(),
				"pom",
				parent.getVersion());
		Dependency dep = new Dependency(art, "compile");
		result.addDependency(dep);
	}
}
 
開發者ID:NixOS,項目名稱:mvn2nix-maven-plugin,代碼行數:17,代碼來源:ParentPOMPropagatingArtifactDescriptorReaderDelegate.java

示例11: saveMavenParentInfo

import org.apache.maven.model.Parent; //導入依賴的package包/類
private void saveMavenParentInfo(MavenProjectInfo projectInfo) throws IOException, XmlPullParserException {
	File mavenProjectPomLocation = projectInfo.getPomFile();// project.getFile(POM_FILE).getLocation().toFile();
	MavenProject mavenProject = null;
	mavenProject = MavenUtils.getMavenProject(mavenProjectPomLocation);
	Parent msf4jParent = new Parent();
	msf4jParent.setGroupId(MSF4J_SERVICE_PARENT_GROUP_ID);
	msf4jParent.setArtifactId(MSF4J_SERVICE_PARENT_ARTIFACT_ID);
	msf4jParent.setVersion(MSF4JArtifactConstants.getMSF4JServiceParentVersion());
	mavenProject.getModel().setParent(msf4jParent);

	Properties generatedProperties = mavenProject.getModel().getProperties();
	generatedProperties.clear();

	mavenProject.getModel().addProperty(MSF4J_MAIN_CLASS_PROPERTY, DEFAULT_MAIN_CLASS_PROPERTY_VALUE);
	MavenUtils.saveMavenProject(mavenProject, mavenProjectPomLocation);
}
 
開發者ID:wso2,項目名稱:msf4j,代碼行數:17,代碼來源:MSF4JProjectImporter.java

示例12: mavenModelToArtifactInfo

import org.apache.maven.model.Parent; //導入依賴的package包/類
public static MavenArtifactInfo mavenModelToArtifactInfo(Model model) {
    Parent parent = model.getParent();
    String groupId = model.getGroupId();
    if (groupId == null && parent != null) {
        groupId = parent.getGroupId();
    }
    MavenArtifactInfo artifactInfo = new MavenArtifactInfo();
    artifactInfo.setGroupId(groupId);
    artifactInfo.setArtifactId(model.getArtifactId());
    String version = model.getVersion();
    if (version == null && parent != null) {
        version = parent.getVersion();
    }
    artifactInfo.setVersion(version);
    return artifactInfo;
}
 
開發者ID:alancnet,項目名稱:artifactory,代碼行數:17,代碼來源:MavenModelUtils.java

示例13: shouldParseParentPomFile

import org.apache.maven.model.Parent; //導入依賴的package包/類
@Test
public void shouldParseParentPomFile() throws IOException {
    Properties properties = new Properties();
    properties.put("test.properties", "testParent");
    // Because we use <version> and <artifactId> tags in our tested pom, the parsing method should add this as properties
    properties.put("project.version", "0-27-SNAPSHOT");
    properties.put("project.artifactId", "motech-platform-server-api");

    try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("pom/parentPom.xml")) {
        pomInformation = new PomInformation();
        pomInformation.parseParentPom(inputStream);
    }

    PomInformation parentPom = pomInformation.getParentPomInformation();
    assertEquals(properties, parentPom.getProperties());

    Parent parentFromParsing = parentPom.getParent();
    assertEquals("0.27-SNAPSHOT", parentFromParsing.getVersion());
    assertEquals("motech", parentFromParsing.getArtifactId());
    assertEquals("org.motechproject", parentFromParsing.getGroupId());
}
 
開發者ID:motech,項目名稱:motech,代碼行數:22,代碼來源:PomInformationTest.java

示例14: getChildModels

import org.apache.maven.model.Parent; //導入依賴的package包/類
/**
 * Returns all the models that have a specified groupId and artifactId as parent.
 *
 * @param reactor    The map of models keyed by path.
 * @param groupId    The groupId of the parent.
 * @param artifactId The artifactId of the parent.
 * @return a map of models that have a specified groupId and artifactId as parent keyed by path.
 */
public static Map<String, Model> getChildModels( Map<String, Model> reactor, String groupId, String artifactId )
{
    final Map<String, Model> result = new LinkedHashMap<String, Model>();
    for ( Map.Entry<String, Model> entry : reactor.entrySet() )
    {
        final String path = entry.getKey();
        final Model model = entry.getValue();
        final Parent parent = model.getParent();
        if ( parent != null && groupId.equals( parent.getGroupId() ) &&
            artifactId.equals( parent.getArtifactId() ) )
        {
            result.put( path, model );
        }
    }
    return result;
}
 
開發者ID:petr-ujezdsky,項目名稱:versions-maven-plugin-svn-clone,代碼行數:25,代碼來源:PomHelper.java

示例15: setParentMavenInfo

import org.apache.maven.model.Parent; //導入依賴的package包/類
private void setParentMavenInfo(Parent info) {
	if (info != null) {
		setParentProjectName(info.getArtifactId());
		setParentGroupID(info.getGroupId());
		setParentArtifactID(info.getArtifactId());
		setParentVersion(info.getVersion());
		setParentRelativePath(info.getRelativePath());
		txtParentArtifactId.setText(getParentArtifactID());
		txtParentGroupId.setText(getParentGroupID());
		txtParentVersion.setText(getParentVersion());
		String parentRelativePath2 = getParentRelativePath();
		if (hasParentProject && parentRelativePath2 != null) {
			txtRelativePath.setText(parentRelativePath2);
		} else {
			txtRelativePath.setText("");
		}
	}

}
 
開發者ID:wso2,項目名稱:developer-studio,代碼行數:20,代碼來源:MavenDetailsPage.java


注:本文中的org.apache.maven.model.Parent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。