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


Java Parent.getVersion方法代碼示例

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


在下文中一共展示了Parent.getVersion方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: getScmUrl

import org.apache.maven.model.Parent; //導入方法依賴的package包/類
/**
 * This method tries to retrieve SCM URL, if POM model for given dependency does not specify SCM URL and
 * parent model belongs to the same group, we'll try to fecth URL from the parent model
 * @param dependency dependency to retrieve SCM URL for
 * @return SCM URL or null
 * @throws IOException
 * @throws XmlPullParserException
 */
private static String getScmUrl(RawDependency dependency) throws IOException, XmlPullParserException {
    Model model = fetchModel(dependency);
    while (model != null) {
        Scm scm = model.getScm();
        if (scm != null) {
            return scm.getUrl();
        }

        Parent parent = model.getParent();
        if (parent == null) {
            return null;
        }
        if (!StringUtils.equals(parent.getGroupId(), dependency.groupID)) {
            return null;
        }
        dependency = new RawDependency(parent.getGroupId(),
                parent.getArtifactId(),
                parent.getVersion(), null, null);
        model = fetchModel(dependency);
    }
    return null;
}
 
開發者ID:sourcegraph,項目名稱:srclib-java,代碼行數:31,代碼來源:Resolver.java

示例7: pomExecution

import org.apache.maven.model.Parent; //導入方法依賴的package包/類
@Override
protected TOExecutionResult pomExecution(String relativePomFile, Model model) {
    String details;
    Parent parent = model.getParent();

    if (parent == null) {
        String message = String.format("Pom file %s does not have a parent", getRelativePath());

        switch (ifNotPresent) {
            case Warn:
                return TOExecutionResult.warning(this, new TransformationOperationException(message));
            case NoOp:
                return TOExecutionResult.noOp(this, message);
            case Fail:
                // Fail is the default
            default:
                return TOExecutionResult.error(this, new TransformationOperationException(message));
        }
    }

    if(groupId != null && artifactId != null && version != null) {
        parent.setGroupId(groupId);
        parent.setArtifactId(artifactId);
        parent.setVersion(version);
        String newParent = parent.toString();
        details = String.format("Parent for POM file (%s) has been set to %s", relativePomFile, newParent);
    } else if (groupId == null && artifactId == null && version != null) {
        String oldVersion = parent.getVersion();
        parent.setVersion(version);
        details = String.format("Parent's version for POM file (%s) has been changed from %s to %s", relativePomFile, oldVersion, version);
    } else {
        // FIXME this should be in a pre-validation
        return TOExecutionResult.error(this, new TransformationOperationException("Invalid POM parent transformation operation"));
    }

    return TOExecutionResult.success(this, details);
}
 
開發者ID:paypal,項目名稱:butterfly,代碼行數:38,代碼來源:PomChangeParent.java

示例8: getLicenses

import org.apache.maven.model.Parent; //導入方法依賴的package包/類
public static List<License> getLicenses(File filePath, String userSettings, String globalSettings)
{
    try
    {
        Model model = new MavenXpp3Reader().read(new FileInputStream(filePath));

        if (!model.getLicenses().isEmpty())
        {
            return model.getLicenses();
        }
        else
        {
            if (model.getParent() != null)
            {
                Parent parent = model.getParent();
                Dependency dependency =
                    new Dependency(parent.getGroupId() + ":" + parent.getArtifactId(), parent.getVersion(), null);
                return getLicenses(DirectoryFinder.getPomPath(dependency,
                    DirectoryFinder.getMavenRepsitoryDir(userSettings, globalSettings)),
                    userSettings, globalSettings);
            }
            else
            {
                return Collections.emptyList();
            }
        }

    }
    catch (Exception e)
    {
        LOGGER.warn("Could not parse Maven POM " + filePath, e);
        return Collections.emptyList();
    }
}
 
開發者ID:porscheinformatik,項目名稱:sonarqube-licensecheck,代碼行數:35,代碼來源:LicenseFinder.java

示例9: resolveModel

import org.apache.maven.model.Parent; //導入方法依賴的package包/類
/**
 * Resolves the POM for the specified parent.
 *
 * @param parent the parent coordinates to resolve, must not be {@code null}
 * @return The source of the requested POM, never {@code null}
 * @since Apache-Maven-3.2.2 (MNG-5639)
 */
public ModelSource resolveModel( Parent parent )
        throws UnresolvableModelException {

    Dependency parentDependency = new Dependency();
    parentDependency.setGroupId(parent.getGroupId());
    parentDependency.setArtifactId(parent.getArtifactId());
    parentDependency.setVersion(parent.getVersion());
    parentDependency.setClassifier("");
    parentDependency.setType("pom");

    Artifact parentArtifact = null;
    try
    {
        Iterable<ArtifactResult> artifactResults = depencencyResolver.resolveDependencies(
                projectBuildingRequest, singleton(parentDependency), null, null );
        Iterator<ArtifactResult> iterator = artifactResults.iterator();
        if (iterator.hasNext()) {
            parentArtifact = iterator.next().getArtifact();
        }
    } catch (DependencyResolverException e) {
        throw new UnresolvableModelException( e.getMessage(), parent.getGroupId(), parent.getArtifactId(),
                parent.getVersion(), e );
    }

    return resolveModel( parentArtifact.getGroupId(), parentArtifact.getArtifactId(), parentArtifact.getVersion() );
}
 
開發者ID:mojohaus,項目名稱:flatten-maven-plugin,代碼行數:34,代碼來源:FlattenModelResolver.java

示例10: getModelVersion

import org.apache.maven.model.Parent; //導入方法依賴的package包/類
private String getModelVersion(Model model) {
    String modelVersion = model.getVersion();
    //Version may come from the parent
    if (StringUtils.isBlank(modelVersion)) {
        Parent parent = model.getParent();
        if (parent != null) {
            modelVersion = parent.getVersion();
        }
    }
    return modelVersion;
}
 
開發者ID:alancnet,項目名稱:artifactory,代碼行數:12,代碼來源:PomTargetPathValidator.java

示例11: modelKey

import org.apache.maven.model.Parent; //導入方法依賴的package包/類
public static ProjectVersionRef modelKey( final Model model )
                throws ManipulationException
{
    String g = model.getGroupId();
    String v = model.getVersion();

    if ( g == null || v == null )
    {
        final Parent p = model.getParent();
        if ( p == null )
        {
            throw new ManipulationException( "Invalid model: " + model + " Cannot find groupId and/or version!" );
        }

        if ( g == null )
        {
            g = p.getGroupId();
        }
        if ( v == null )
        {
            v = p.getVersion();
        }
    }

    final String a = model.getArtifactId();
    return new SimpleProjectVersionRef( g, a, v );
}
 
開發者ID:release-engineering,項目名稱:pom-manipulation-ext,代碼行數:28,代碼來源:Project.java

示例12: mergeParent_Version

import org.apache.maven.model.Parent; //導入方法依賴的package包/類
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" ) );
        }
    }
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:14,代碼來源:ModelMerger.java

示例13: readParent

import org.apache.maven.model.Parent; //導入方法依賴的package包/類
private ModelData readParent( Model childModel, ModelBuildingRequest request,
                              DefaultModelProblemCollector problems )
    throws ModelBuildingException
{
    ModelData parentData;

    Parent parent = childModel.getParent();

    if ( parent != null )
    {
        String groupId = parent.getGroupId();
        String artifactId = parent.getArtifactId();
        String version = parent.getVersion();

        parentData = getCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.RAW );

        if ( parentData == null )
        {
            parentData = readParentLocally( childModel, request, problems );

            if ( parentData == null )
            {
                parentData = readParentExternally( childModel, request, problems );
            }

            putCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.RAW, parentData );
        }
        else
        {
            /*
             * NOTE: This is a sanity check of the cache hit. If the cached parent POM was locally resolved, the
             * child's <relativePath> should point at that parent, too. If it doesn't, we ignore the cache and
             * resolve externally, to mimic the behavior if the cache didn't exist in the first place. Otherwise,
             * the cache would obscure a bad POM.
             */

            File pomFile = parentData.getModel().getPomFile();
            if ( pomFile != null )
            {
                File expectedParentFile = getParentPomFile( childModel );

                if ( !pomFile.equals( expectedParentFile ) )
                {
                    parentData = readParentExternally( childModel, request, problems );
                }
            }
        }

        Model parentModel = parentData.getModel();

        if ( !"pom".equals( parentModel.getPackaging() ) )
        {
            problems.add( new ModelProblemCollectorRequest(Severity.ERROR, Version.BASE)
                    .setMessage( "Invalid packaging for parent POM " + ModelProblemUtils.toSourceHint( parentModel ) + ", must be \"pom\" but is \""
                                + parentModel.getPackaging() + "\"")
                    .setLocation(parentModel.getLocation( "packaging" )));
        }
    }
    else
    {
        parentData = null;
    }

    return parentData;
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:66,代碼來源:DefaultModelBuilder.java

示例14: readParentExternally

import org.apache.maven.model.Parent; //導入方法依賴的package包/類
private ModelData readParentExternally( Model childModel, ModelBuildingRequest request,
                                        DefaultModelProblemCollector problems )
    throws ModelBuildingException
{
    problems.setSource( childModel );

    Parent parent = childModel.getParent();

    String groupId = parent.getGroupId();
    String artifactId = parent.getArtifactId();
    String version = parent.getVersion();

    ModelResolver modelResolver = request.getModelResolver();

    if ( modelResolver == null )
    {
        throw new IllegalArgumentException( "no model resolver provided, cannot resolve parent POM "
            + ModelProblemUtils.toId( groupId, artifactId, version ) + " for POM "
            + ModelProblemUtils.toSourceHint( childModel ) );
    }

    ModelSource modelSource;
    try
    {
        modelSource = modelResolver.resolveModel( groupId, artifactId, version );
    }
    catch ( UnresolvableModelException e )
    {
        StringBuilder buffer = new StringBuilder( 256 );
        buffer.append( "Non-resolvable parent POM" );
        if ( !containsCoordinates( e.getMessage(), groupId, artifactId, version ) )
        {
            buffer.append( " " ).append( ModelProblemUtils.toId( groupId, artifactId, version ) );
        }
        if ( childModel != problems.getRootModel() )
        {
            buffer.append( " for " ).append( ModelProblemUtils.toId( childModel ) );
        }
        buffer.append( ": " ).append( e.getMessage() );
        if ( childModel.getProjectDirectory() != null )
        {
            if ( parent.getRelativePath() == null || parent.getRelativePath().length() <= 0 )
            {
                buffer.append( " and 'parent.relativePath' points at no local POM" );
            }
            else
            {
                buffer.append( " and 'parent.relativePath' points at wrong local POM" );
            }
        }

        problems.add( new ModelProblemCollectorRequest(Severity.FATAL, Version.BASE)
                .setMessage( buffer.toString())
                .setLocation(parent.getLocation( "" ))
                .setException(e));
        throw problems.newModelBuildingException();
    }

    ModelBuildingRequest lenientRequest = request;
    if ( request.getValidationLevel() > ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0 )
    {
        lenientRequest = new FilterModelBuildingRequest( request )
        {
            @Override
            public int getValidationLevel()
            {
                return ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_2_0;
            }
        };
    }

    Model parentModel = readModel( modelSource, null, lenientRequest, problems );

    ModelData parentData = new ModelData( parentModel, groupId, artifactId, version );

    return parentData;
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:78,代碼來源:DefaultModelBuilder.java


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