Example usage for org.apache.maven.repository.metadata ArtifactMetadata ArtifactMetadata

List of usage examples for org.apache.maven.repository.metadata ArtifactMetadata ArtifactMetadata

Introduction

In this page you can find the example usage for org.apache.maven.repository.metadata ArtifactMetadata ArtifactMetadata.

Prototype

public ArtifactMetadata(String groupId, String name, String version, String type,
            ArtifactScopeEnum artifactScope, String classifier) 

Source Link

Usage

From source file:org.maven.ide.eclipse.annotations.ProcessorConfiguration.java

License:Open Source License

private void configure() {
    // aggregate plugin executions (can there be more than one?):
    List<PluginExecution> executions = m_plugin.getExecutions();

    for (PluginExecution pluginExecution : executions) {
        Xpp3Dom configuration = (Xpp3Dom) pluginExecution.getConfiguration();

        if (configuration == null) {
            throw new IllegalStateException(errorMsg("Plugin execution does not have configuration element."));
        }//from  w w w .j a va2 s.c o m

        Xpp3Dom outputDirectoryElement = configuration.getChild("outputDirectory");
        if (outputDirectoryElement != null) {
            if (m_outputDirectory != null) {
                // output directory already set, replacing it
            }
            m_outputDirectory = outputDirectoryElement.getValue();
        }

        Xpp3Dom processors = configuration.getChild("processors");
        if (processors != null) {
            Xpp3Dom[] processorElements = processors.getChildren("processor");

            if (processorElements == null) {
                throw new IllegalStateException(errorMsg("There are no processors elements."));
            }

            for (Xpp3Dom processorElement : processorElements) {
                if (processorElement != null) {
                    m_annotationProcessors.add(processorElement.getValue());
                }
            }
        }

        Xpp3Dom optionMap = configuration.getChild("optionMap");
        if (optionMap != null) {
            Xpp3Dom[] keys = optionMap.getChildren();
            for (Xpp3Dom key : keys) {
                String optionName = key.getName();
                String optionValue = key.getValue();
                m_optionMap.put(optionName, optionValue);
            }
        }
    }

    // dependencies = artifacts that contain annotation processors
    List<Dependency> dependencies = m_plugin.getDependencies();
    for (Dependency dependency : dependencies) {
        String scopeString = dependency.getScope();
        ArtifactScopeEnum scope = ArtifactScopeEnum.valueOf(scopeString);
        ArtifactMetadata artifactMetadata = new ArtifactMetadata(dependency.getGroupId(),
                dependency.getArtifactId(), dependency.getVersion(), dependency.getType(), scope,
                dependency.getClassifier());
        m_processorArtifacts.add(artifactMetadata);
    }

}

From source file:org.maven.ide.querydsl.QueryDslConfiguration.java

License:Open Source License

private void configure() throws CoreException {
    // determine apt library that should be downloaded based on the
    // type of annotation processor:
    ////  w ww .ja  v a  2 s  . c o  m
    // jdo        : com.mysema.query.apt.jdo.JDOAnnotationProcessor
    // jpa        : com.mysema.query.apt.jpa.JPAAnnotationProcessor
    // hibernate  : com.mysema.query.apt.hibernate.HibernateAnnotationProcessor
    // collections: com.mysema.query.apt.QuerydslAnnotationProcessor
    Map<String, ArtifactMetadata> MAP_PROCESSORS_TO_ARTIFACTMETADATA = new HashMap<String, ArtifactMetadata>() {
        {
            //                put(PROCESSOR_COLLECTIONS, new ArtifactMetadata("com.mysema.querydsl", "querydsl-jdo", m_queryDslVersion, "jar", ArtifactScopeEnum.compile, "apt-one-jar"));
            put(PROCESSOR_HIBERNATE, new ArtifactMetadata("com.mysema.querydsl", "querydsl-jpa",
                    m_queryDslVersion, "jar", ArtifactScopeEnum.compile, "apt-hibernate-one-jar"));
            put(PROCESSOR_JDO, new ArtifactMetadata("com.mysema.querydsl", "querydsl-jdo", m_queryDslVersion,
                    "jar", ArtifactScopeEnum.compile, "apt-one-jar"));
            put(PROCESSOR_JPA, new ArtifactMetadata("com.mysema.querydsl", "querydsl-jpa", m_queryDslVersion,
                    "jar", ArtifactScopeEnum.compile, "apt-one-jar"));
        }
    };

    // aggregate plugin executions (can there be more than one?):
    List<PluginExecution> executions = m_plugin.getExecutions();

    List<ArtifactMetadata> processorArtifacts = new ArrayList<ArtifactMetadata>();

    for (PluginExecution pluginExecution : executions) {
        Xpp3Dom configuration = (Xpp3Dom) pluginExecution.getConfiguration();

        if (configuration == null) {
            String msg = MessageUtils.info(m_plugin, "Plugin execution does not have configuration element.");
            throw new IllegalStateException(msg);
        }

        Xpp3Dom outputDirectoryElement = configuration.getChild("outputDirectory");
        if (outputDirectoryElement != null) {
            m_outputDirectory = outputDirectoryElement.getValue();
        }

        Xpp3Dom processorElement = configuration.getChild("processor");
        if (processorElement != null) {
            m_annotationProcessor = processorElement.getValue();
            if (null == m_annotationProcessor) {
                String msg = MessageUtils.info(m_plugin,
                        "Configuration element does not define processor value.");
                throw new IllegalStateException(msg);
            }
            ArtifactMetadata artifactMetadata = MAP_PROCESSORS_TO_ARTIFACTMETADATA.get(m_annotationProcessor);
            if (null != artifactMetadata) {
                processorArtifacts.add(artifactMetadata);
            } else {
                // search explicit plugin dependencies
                ArtifactMetadata processorArtifactMetadata = searchDependencies(m_annotationProcessor);
                if (null != processorArtifactMetadata) {
                    processorArtifacts.add(processorArtifactMetadata);
                } else {
                    String msg = MessageUtils.info(m_plugin,
                            "Unable to find artifact metadata for processor '%s'", m_annotationProcessor);
                    log.warn(msg);
                    // Alternative: just add defined dependencies and let us hope everything will work

                    // we can't handle this scenario
                    throw new IllegalStateException(msg);
                }
                // finally: add all plugin dependencies
                processorArtifacts.addAll(pluginDependenciesAsArtifacts());
            }
        } else {
            String msg = MessageUtils.info(m_plugin, "Configuration element does not define processor.");
            throw new IllegalStateException(msg);
        }

    }

    m_processorArtifacts = processorArtifacts.toArray(new ArtifactMetadata[0]);
}

From source file:org.maven.ide.querydsl.QueryDslConfiguration.java

License:Open Source License

private ArtifactMetadata toArtifactMetaData(Dependency p_dependency) {
    ArtifactMetadata artifactMetadata = new ArtifactMetadata(p_dependency.getGroupId(),
            p_dependency.getArtifactId(), p_dependency.getVersion(), p_dependency.getType(),
            ArtifactScopeEnum.valueOf(p_dependency.getScope()), p_dependency.getClassifier());
    return artifactMetadata;
}