Example usage for org.apache.maven.execution MavenExecutionRequest setProfiles

List of usage examples for org.apache.maven.execution MavenExecutionRequest setProfiles

Introduction

In this page you can find the example usage for org.apache.maven.execution MavenExecutionRequest setProfiles.

Prototype

MavenExecutionRequest setProfiles(List<Profile> profiles);

Source Link

Usage

From source file:org.maven.ide.eclipse.embedder.MavenModelManager.java

License:Apache License

public MavenExecutionResult readMavenProject(File pomFile, IProgressMonitor monitor, //
        boolean offline, boolean debug, ResolverConfiguration resolverConfiguration, MavenEmbedder embedder) {
    try {//from   www. j a  v a 2 s  . c  o m
        // monitor.subTask("Reading " + pomFile.getFullPath());
        // File file = pomFile.getLocation().toFile();

        MavenExecutionRequest request = EmbedderFactory.createMavenExecutionRequest(embedder, offline, debug);
        request.setPomFile(pomFile.getAbsolutePath());
        request.setBaseDirectory(pomFile.getParentFile());
        request.setTransferListener(new TransferListenerAdapter(monitor, console, indexManager));
        request.setProfiles(resolverConfiguration.getActiveProfileList());
        request.addActiveProfiles(resolverConfiguration.getActiveProfileList());

        return embedder.readProjectWithDependencies(request);

        // XXX need to manage markers somehow see MNGECLIPSE-***
        // Util.deleteMarkers(pomFile);

        //      if(!result.hasExceptions()) {
        //        return result.getMavenProject();
        //      }
        //      
        //      return result.getMavenProject();

        //    } catch(Exception ex) {
        //      Util.deleteMarkers(this.file);
        //      Util.addMarker(this.file, "Unable to read project; " + ex.toString(), 1, IMarker.SEVERITY_ERROR);
        //      
        //      String msg = "Unable to read " + file.getLocation() + "; " + ex.toString();
        //      console.logError(msg);
        //      Maven2Plugin.log(msg, ex);

    } finally {
        monitor.done();
    }
}