Search in sources :

Example 16 with Profile

use of org.apache.maven.model.Profile in project maven-plugins by apache.

the class AllProfilesMojo method writeProfilesDescription.

// ----------------------------------------------------------------------
// Private methods
// ----------------------------------------------------------------------
private void writeProfilesDescription(StringBuilder sb, Map<String, Profile> profilesByIds, boolean active) {
    for (Profile p : profilesByIds.values()) {
        sb.append("  Profile Id: ").append(p.getId());
        sb.append(" (Active: " + active + " , Source: ").append(p.getSource()).append(")");
        sb.append(LS);
    }
}
Also used : Profile(org.apache.maven.model.Profile)

Example 17 with Profile

use of org.apache.maven.model.Profile in project maven-plugins by apache.

the class MavenJDOMWriter method iterateProfile.

// -- void iteratePluginExecution(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
 * Method iterateProfile
 *
 * @param counter
 * @param childTag
 * @param parentTag
 * @param list
 * @param parent
 */
protected void iterateProfile(Counter counter, Element parent, Collection<Profile> 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<?> elIt = element.getChildren(childTag, element.getNamespace()).iterator();
        if (!elIt.hasNext()) {
            elIt = null;
        }
        Counter innerCount = new Counter(counter.getDepth() + 1);
        for (Profile value : list) {
            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);
            }
            updateProfile(value, childTag, innerCount, el);
            innerCount.increaseCount();
        }
        if (elIt != null) {
            while (elIt.hasNext()) {
                elIt.next();
                elIt.remove();
            }
        }
    }
}
Also used : Element(org.jdom.Element) Profile(org.apache.maven.model.Profile)

Example 18 with Profile

use of org.apache.maven.model.Profile in project sts4 by spring-projects.

the class MavenBridge method getArtifactRepositories.

public List<ArtifactRepository> getArtifactRepositories(boolean injectSettings) throws MavenException {
    ArrayList<ArtifactRepository> repositories = new ArrayList<ArtifactRepository>();
    for (Profile profile : getActiveProfiles()) {
        addArtifactRepositories(repositories, profile.getRepositories());
    }
    addDefaultRepository(repositories);
    if (injectSettings) {
        injectSettings(repositories);
    }
    return removeDuplicateRepositories(repositories);
}
Also used : ArrayList(java.util.ArrayList) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) Profile(org.apache.maven.model.Profile)

Example 19 with Profile

use of org.apache.maven.model.Profile in project sts4 by spring-projects.

the class MavenBridge method getPluginArtifactRepositories.

public List<ArtifactRepository> getPluginArtifactRepositories(boolean injectSettings) throws MavenException {
    ArrayList<ArtifactRepository> repositories = new ArrayList<ArtifactRepository>();
    for (Profile profile : getActiveProfiles()) {
        addArtifactRepositories(repositories, profile.getPluginRepositories());
    }
    addDefaultRepository(repositories);
    if (injectSettings) {
        injectSettings(repositories);
    }
    return removeDuplicateRepositories(repositories);
}
Also used : ArrayList(java.util.ArrayList) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) Profile(org.apache.maven.model.Profile)

Example 20 with Profile

use of org.apache.maven.model.Profile in project drools by kiegroup.

the class MavenEmbedder method buildMavenExecutionRequest.

protected MavenExecutionRequest buildMavenExecutionRequest(MavenRequest mavenRequest) throws MavenEmbedderException, ComponentLookupException {
    MavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest();
    if (mavenRequest.getGlobalSettingsFile() != null) {
        mavenExecutionRequest.setGlobalSettingsFile(new File(mavenRequest.getGlobalSettingsFile()));
    }
    SettingsSource userSettings = mavenRequest.getUserSettingsSource();
    if (userSettings != null) {
        if (userSettings instanceof FileSettingsSource) {
            mavenExecutionRequest.setUserSettingsFile(((FileSettingsSource) userSettings).getSettingsFile());
        } else {
            try {
                mavenExecutionRequest.setUserSettingsFile(copyInTempFile(userSettings.getInputStream(), "xml"));
            } catch (IOException ioe) {
                log.warn("Unable to use maven settings defined in " + userSettings, ioe);
            }
        }
    }
    try {
        componentProvider.lookup(MavenExecutionRequestPopulator.class).populateFromSettings(mavenExecutionRequest, getSettings());
        componentProvider.lookup(MavenExecutionRequestPopulator.class).populateDefaults(mavenExecutionRequest);
    } catch (MavenExecutionRequestPopulationException e) {
        throw new MavenEmbedderException(e.getMessage(), e);
    }
    ArtifactRepository localRepository = getLocalRepository();
    mavenExecutionRequest.setLocalRepository(localRepository);
    mavenExecutionRequest.setLocalRepositoryPath(localRepository.getBasedir());
    mavenExecutionRequest.setOffline(mavenRequest.isOffline());
    mavenExecutionRequest.setUpdateSnapshots(mavenRequest.isUpdateSnapshots());
    // TODO check null and create a console one ?
    mavenExecutionRequest.setTransferListener(mavenRequest.getTransferListener());
    mavenExecutionRequest.setCacheNotFound(mavenRequest.isCacheNotFound());
    mavenExecutionRequest.setCacheTransferError(true);
    mavenExecutionRequest.setUserProperties(mavenRequest.getUserProperties());
    mavenExecutionRequest.getSystemProperties().putAll(System.getProperties());
    if (mavenRequest.getSystemProperties() != null) {
        mavenExecutionRequest.getSystemProperties().putAll(mavenRequest.getSystemProperties());
    }
    mavenExecutionRequest.getSystemProperties().putAll(getEnvVars());
    if (mavenRequest.getProfiles() != null && !mavenRequest.getProfiles().isEmpty()) {
        for (String id : mavenRequest.getProfiles()) {
            Profile p = new Profile();
            p.setId(id);
            p.setSource("cli");
            mavenExecutionRequest.addProfile(p);
            mavenExecutionRequest.addActiveProfile(id);
        }
    }
    MavenRepositoryConfiguration mavenRepoConf = getMavenRepositoryConfiguration();
    // DROOLS-899: Copy repositories defined in settings to execution request
    for (ArtifactRepository artifactRepository : mavenRepoConf.getArtifactRepositoriesForRequest()) {
        mavenExecutionRequest.addRemoteRepository(artifactRepository);
    }
    mavenExecutionRequest.setProxies(mavenRepoConf.getProxies());
    mavenExecutionRequest.setLoggingLevel(mavenRequest.getLoggingLevel());
    componentProvider.lookup(Logger.class).setThreshold(mavenRequest.getLoggingLevel());
    mavenExecutionRequest.setExecutionListener(mavenRequest.getExecutionListener()).setInteractiveMode(mavenRequest.isInteractive()).setGlobalChecksumPolicy(mavenRequest.getGlobalChecksumPolicy()).setGoals(mavenRequest.getGoals());
    if (mavenRequest.getPom() != null) {
        mavenExecutionRequest.setPom(new File(mavenRequest.getPom()));
    }
    if (mavenRequest.getWorkspaceReader() != null) {
        mavenExecutionRequest.setWorkspaceReader(mavenRequest.getWorkspaceReader());
    }
    if (mavenRequest.getBaseDirectory() != null) {
        mavenExecutionRequest.setBaseDirectory(new File(mavenRequest.getBaseDirectory()));
    }
    return mavenExecutionRequest;
}
Also used : FileSettingsSource(org.apache.maven.settings.building.FileSettingsSource) SettingsSource(org.apache.maven.settings.building.SettingsSource) MavenExecutionRequestPopulationException(org.apache.maven.execution.MavenExecutionRequestPopulationException) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) IOException(java.io.IOException) MavenRepositoryConfiguration(org.kie.maven.integration.MavenRepositoryConfiguration) Logger(org.codehaus.plexus.logging.Logger) Profile(org.apache.maven.model.Profile) FileSettingsSource(org.apache.maven.settings.building.FileSettingsSource) File(java.io.File) IoUtils.copyInTempFile(org.kie.maven.integration.IoUtils.copyInTempFile) MavenExecutionRequestPopulator(org.apache.maven.execution.MavenExecutionRequestPopulator)

Aggregations

Profile (org.apache.maven.model.Profile)52 HashMap (java.util.HashMap)12 Model (org.apache.maven.model.Model)12 ArrayList (java.util.ArrayList)9 Dependency (org.apache.maven.model.Dependency)8 HashSet (java.util.HashSet)7 DependencyManagement (org.apache.maven.model.DependencyManagement)7 File (java.io.File)6 Activation (org.apache.maven.model.Activation)6 MavenProject (org.apache.maven.project.MavenProject)6 Project (org.commonjava.maven.ext.common.model.Project)6 Build (org.apache.maven.model.Build)5 ArtifactRef (org.commonjava.maven.atlas.ident.ref.ArtifactRef)5 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)5 SimpleArtifactRef (org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef)5 SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)5 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)4 ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)3 IOException (java.io.IOException)3 Iterator (java.util.Iterator)3