Java 类org.apache.maven.model.Extension 实例源码

项目:incubator-netbeans    文件:LocationAwareMavenXpp3Writer.java   
private void writeExtension(Extension extension, String tagName, XmlSerializer serializer)
        throws java.io.IOException {
    serializer.startTag(NAMESPACE, tagName);
    flush(serializer);
    StringBuffer b = b(serializer);
    int start = b.length();
    if (extension.getGroupId() != null) {
        writeValue(serializer, "groupId", extension.getGroupId(), extension);
    }
    if (extension.getArtifactId() != null) {
        writeValue(serializer, "artifactId", extension.getArtifactId(), extension);
    }
    if (extension.getVersion() != null) {
        writeValue(serializer, "version", extension.getVersion(), extension);
    }
    serializer.endTag(NAMESPACE, tagName).flush();
    logLocation(extension, "", start, b.length());
}
项目:xmvn    文件:XMvnModelValidator.java   
void customizeModel( Model model )
{
    BuildSettings settings = configurator.getConfiguration().getBuildSettings();
    Build build = model.getBuild() != null ? model.getBuild() : new Build();
    List<Dependency> dependencies = model.getDependencies();
    List<Extension> extensions = build.getExtensions();
    List<Plugin> plugins = build.getPlugins();

    if ( settings.isSkipTests() )
        dependencies.removeIf( d -> StringUtils.equals( d.getScope(), "test" ) );

    dependencies.forEach( d -> d.setVersion( replaceVersion( d.getGroupId(), d.getArtifactId(),
                                                             d.getVersion() ) ) );
    extensions.forEach( e -> e.setVersion( replaceVersion( e.getGroupId(), e.getArtifactId(), e.getVersion() ) ) );
    plugins.forEach( p -> p.setVersion( replaceVersion( p.getGroupId(), p.getArtifactId(), p.getVersion() ) ) );

    plugins.stream().filter( p -> p.getGroupId().equals( "org.apache.maven.plugins" )
        && p.getArtifactId().equals( "maven-compiler-plugin" ) ).forEach( p -> configureCompiler( p ) );
}
项目:apache-maven-shade-plugin    文件:MavenJDOMWriter.java   
/**
 * Method updateExtension
 *
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
protected void updateExtension( Extension value, String xmlTag, Counter counter, Element element )
{
    Element root = element;
    Counter innerCount = new Counter( counter.getDepth() + 1 );
    findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null );
    findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null );
    findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null );
}
项目:maven-shade-plugin    文件:MavenJDOMWriter.java   
/**
 * Method updateExtension
 *
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
protected void updateExtension( Extension value, String xmlTag, Counter counter, Element element )
{
    Element root = element;
    Counter innerCount = new Counter( counter.getDepth() + 1 );
    findAndReplaceSimpleElement( innerCount, root, "groupId", value.getGroupId(), null );
    findAndReplaceSimpleElement( innerCount, root, "artifactId", value.getArtifactId(), null );
    findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null );
}
项目:oceano    文件:DefaultModelInheritanceAssembler.java   
private static void mergeExtensionLists( Build childBuild, Build parentBuild )
{
    for ( Extension e : parentBuild.getExtensions() )
    {
        if ( !childBuild.getExtensions().contains( e ) )
        {
            childBuild.addExtension( e );
        }
    }
}
项目:oceano    文件:MavenProject.java   
public Set<Artifact> getExtensionArtifacts()
{
    if ( extensionArtifacts != null )
    {
        return extensionArtifacts;
    }
    extensionArtifacts = new HashSet<Artifact>();
    List<Extension> extensions = getBuildExtensions();
    if ( extensions != null )
    {
        for ( Iterator<Extension> i = extensions.iterator(); i.hasNext(); )
        {
            Extension ext = i.next();

            String version;
            if ( StringUtils.isEmpty( ext.getVersion() ) )
            {
                version = "RELEASE";
            }
            else
            {
                version = ext.getVersion();
            }

            Artifact artifact = repositorySystem.createArtifact( ext.getGroupId(), ext.getArtifactId(), version, null, "jar" );

            if ( artifact != null )
            {
                extensionArtifacts.add( artifact );
            }
        }
    }
    extensionArtifactMap = null;
    return extensionArtifacts;
}
项目:oceano    文件:MavenProject.java   
public List<Extension> getBuildExtensions()
{
    Build build = getBuild();
    if ( ( build == null ) || ( build.getExtensions() == null ) )
    {
        return Collections.emptyList();
    }
    else
    {
        return build.getExtensions();
    }
}
项目:oceano    文件:ProjectSorterTest.java   
private Extension createExtension( String groupId, String artifactId, String version )
{
    Extension extension = new Extension();
    extension.setGroupId( groupId );
    extension.setArtifactId( artifactId );
    extension.setVersion( version );
    return extension;
}
项目:oceano    文件:ModelMerger.java   
protected void mergeExtension( Extension target, Extension source, boolean sourceDominant,
                               Map<Object, Object> context )
{
    mergeExtension_GroupId( target, source, sourceDominant, context );
    mergeExtension_ArtifactId( target, source, sourceDominant, context );
    mergeExtension_Version( target, source, sourceDominant, context );
}
项目:oceano    文件:ModelMerger.java   
protected void mergeExtension_GroupId( Extension target, Extension source, boolean sourceDominant,
                                       Map<Object, Object> context )
{
    String src = source.getGroupId();
    if ( src != null )
    {
        if ( sourceDominant || target.getGroupId() == null )
        {
            target.setGroupId( src );
            target.setLocation( "groupId", source.getLocation( "groupId" ) );
        }
    }
}
项目:oceano    文件:ModelMerger.java   
protected void mergeExtension_ArtifactId( Extension target, Extension 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" ) );
        }
    }
}
项目:oceano    文件:ModelMerger.java   
protected void mergeExtension_Version( Extension target, Extension 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" ) );
        }
    }
}
项目:xmvn    文件:AbstractModelVisitor.java   
@Override
public Extension replaceBuildExtension( Extension extension )
{
    return extension;
}
项目:xmvn    文件:AbstractModelVisitor.java   
@Override
public void visitBuildExtension( Extension extension )
{
}
项目:xmvn    文件:BuildDependencyVisitor.java   
@Override
public void visitBuildExtension( Extension extension )
{
    artifacts.add( new DefaultArtifact( extension.getGroupId(), extension.getArtifactId(),
                                        extension.getVersion() ) );
}
项目:maven-shade-plugin    文件:MavenJDOMWriter.java   
/**
 * Method iterateExtension
 *
 * @param counter
 * @param childTag
 * @param parentTag
 * @param list
 * @param parent
 */
protected void iterateExtension( Counter counter, Element parent, java.util.Collection list,
                                 java.lang.String parentTag, java.lang.String childTag )
{
    boolean shouldExist = list != null && list.size() > 0;
    Element element = updateElement( counter, parent, parentTag, shouldExist );
    if ( shouldExist )
    {
        Iterator it = list.iterator();
        Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator();
        if ( !elIt.hasNext() )
        {
            elIt = null;
        }
        Counter innerCount = new Counter( counter.getDepth() + 1 );
        while ( it.hasNext() )
        {
            Extension value = (Extension) it.next();
            Element el;
            if ( elIt != null && elIt.hasNext() )
            {
                el = (Element) elIt.next();
                if ( !elIt.hasNext() )
                {
                    elIt = null;
                }
            }
            else
            {
                el = factory.element( childTag, element.getNamespace() );
                insertAtPreferredLocation( element, el, innerCount );
            }
            updateExtension( value, childTag, innerCount, el );
            innerCount.increaseCount();
        }
        if ( elIt != null )
        {
            while ( elIt.hasNext() )
            {
                elIt.next();
                elIt.remove();
            }
        }
    }
}
项目:qulice    文件:SnapshotsValidator.java   
/**
 * Check all plugins and deps.
 * @param env Environment
 * @throws ValidationException If fails
 */
private void check(final MavenEnvironment env) throws ValidationException {
    int errors = 0;
    for (final Extension ext : env.project().getBuildExtensions()) {
        if (SnapshotsValidator.isSnapshot(ext.getVersion())) {
            Logger.warn(
                this,
                "%s build extension is SNAPSHOT",
                ext
            );
            ++errors;
        }
    }
    for (final Plugin plugin : env.project().getBuildPlugins()) {
        if (SnapshotsValidator.isSnapshot(plugin.getVersion())) {
            Logger.warn(
                this,
                "%s build plugin is SNAPSHOT",
                plugin
            );
            ++errors;
        }
    }
    for (final Dependency dep : env.project().getDependencies()) {
        if (SnapshotsValidator.isSnapshot(dep.getVersion())) {
            Logger.warn(
                this,
                "%s dependency is SNAPSHOT",
                dep
            );
            ++errors;
        }
    }
    if (errors > 0) {
        Logger.warn(
            this,
            // @checkstyle LineLength (1 line)
            "The version of the project is not SNAPSHOT; there shouldn't not be any SNAPSHOT dependencies (%d found)",
            errors
        );
        throw new ValidationException(
            "%d dependencies are in SNAPSHOT state",
            errors
        );
    }
}
项目:oceano    文件:ModelMerger.java   
protected Object getExtensionKey( Extension object )
{
    return object;
}
项目:oceano    文件:MavenModelMerger.java   
@Override
protected Object getExtensionKey( Extension object )
{
    return object.getGroupId() + ':' + object.getArtifactId();
}
项目:jcabi-heroku-maven-plugin    文件:DeployMojoTest.java   
/**
 * DeployMojo can generate correct settings.xml file.
 * @throws Exception If something is wrong
 */
@Test
public void velocityTemplateCorrectlyBuildsPomXml() throws Exception {
    final Build build = new Build();
    final Extension ext = new Extension();
    ext.setArtifactId("test-foo");
    build.addExtension(ext);
    final MavenProject project = new MavenProject();
    project.setBuild(build);
    final String nspace = "http://maven.apache.org/POM/4.0.0";
    MatcherAssert.assertThat(
        new VelocityPage(
            "com/jcabi/heroku/maven/plugin/pom.xml.vm"
        ).set("project", project)
            .set("timestamp", "332211")
            .set(
                "deps",
                Arrays.asList(
                    new DefaultArtifact("fooo", "", "", "", "", "", null)
                )
            )
            .toString(),
        Matchers.allOf(
            XhtmlMatchers.hasXPath(
                "//ns1:name[.='332211']",
                nspace
            ),
            XhtmlMatchers.hasXPath(
                "//ns1:extension[ns1:artifactId='test-foo']",
                nspace
            ),
            XhtmlMatchers.hasXPath(
                "//ns1:dependency[ns1:groupId='fooo']",
                nspace
            ),
            XhtmlMatchers.hasXPath(
                "//ns1:configuration[ns1:outputDirectory='${basedir}']",
                nspace
            )
        )
    );
}
项目:oceano    文件:ProjectSorterTest.java   
public void testShouldNotFailWhenProjectReferencesNonExistentProject()
    throws CycleDetectedException, DuplicateProjectException
{
    MavenProject project = createProject( "group", "artifact", "1.0" );

    Build build = project.getModel().getBuild();

    Extension extension = createExtension( "other.group", "other-artifact", "1.0" );

    build.addExtension( extension );

    new ProjectSorter( Collections.singletonList( project ) );
}
项目:xmvn    文件:ModelVisitor.java   
Extension replaceBuildExtension( Extension extension );
项目:xmvn    文件:ModelVisitor.java   
void visitBuildExtension( Extension extension );