Search in sources :

Example 1 with ProjectBuilderConfiguration

use of org.apache.maven.project.ProjectBuilderConfiguration in project che by eclipse.

the class MavenServerImpl method internalInterpolate.

private static Model internalInterpolate(Model model, File projectDir) throws RemoteException {
    try {
        AbstractStringBasedModelInterpolator interpolator = new org.apache.maven.project.interpolation.StringSearchModelInterpolator(new DefaultPathTranslator());
        interpolator.initialize();
        //MavenServerUtil.collectSystemProperties();
        Properties props = new Properties();
        ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setExecutionProperties(props);
        config.setBuildStartTime(new Date());
        model = interpolator.interpolate(model, projectDir, config, false);
    } catch (ModelInterpolationException e) {
        MavenServerContext.getLogger().warning(e);
    } catch (InitializationException e) {
        MavenServerContext.getLogger().error(e);
    }
    return model;
}
Also used : ProjectBuilderConfiguration(org.apache.maven.project.ProjectBuilderConfiguration) DefaultProjectBuilderConfiguration(org.apache.maven.project.DefaultProjectBuilderConfiguration) ModelInterpolationException(org.apache.maven.project.interpolation.ModelInterpolationException) AbstractStringBasedModelInterpolator(org.apache.maven.project.interpolation.AbstractStringBasedModelInterpolator) DefaultPathTranslator(org.apache.maven.project.path.DefaultPathTranslator) DefaultProjectBuilderConfiguration(org.apache.maven.project.DefaultProjectBuilderConfiguration) Properties(java.util.Properties) InitializationException(org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException) Date(java.util.Date)

Example 2 with ProjectBuilderConfiguration

use of org.apache.maven.project.ProjectBuilderConfiguration in project intellij-community by JetBrains.

the class MavenEmbedder method resolveProject.

@NotNull
public MavenExecutionResult resolveProject(@NotNull final File file, @NotNull final List<String> activeProfiles, @NotNull final List<String> inactiveProfiles, List<ResolutionListener> listeners) {
    MavenExecutionRequest request = createRequest(file, activeProfiles, inactiveProfiles, Collections.<String>emptyList());
    ProjectBuilderConfiguration config = request.getProjectBuilderConfiguration();
    request.getGlobalProfileManager().loadSettingsProfiles(mySettings);
    ProfileManager globalProfileManager = request.getGlobalProfileManager();
    globalProfileManager.loadSettingsProfiles(request.getSettings());
    List<Exception> exceptions = new ArrayList<Exception>();
    MavenProject project = null;
    try {
        // copied from DefaultMavenProjectBuilder.buildWithDependencies
        MavenProjectBuilder builder = getComponent(MavenProjectBuilder.class);
        project = builder.build(new File(file.getPath()), config);
        builder.calculateConcreteState(project, config, false);
        // copied from DefaultLifecycleExecutor.execute
        findExtensions(project);
        // end copied from DefaultLifecycleExecutor.execute
        Artifact projectArtifact = project.getArtifact();
        Map managedVersions = project.getManagedVersionMap();
        ArtifactMetadataSource metadataSource = getComponent(ArtifactMetadataSource.class);
        project.setDependencyArtifacts(project.createArtifacts(getComponent(ArtifactFactory.class), null, null));
        ArtifactResolver resolver = getComponent(ArtifactResolver.class);
        ArtifactResolutionResult result = resolver.resolveTransitively(project.getDependencyArtifacts(), projectArtifact, managedVersions, myLocalRepository, project.getRemoteArtifactRepositories(), metadataSource, null, listeners);
        project.setArtifacts(result.getArtifacts());
    // end copied from DefaultMavenProjectBuilder.buildWithDependencies
    } catch (Exception e) {
        return handleException(e);
    }
    return new MavenExecutionResult(project, exceptions);
}
Also used : DefaultProfileManager(org.apache.maven.profiles.DefaultProfileManager) ProfileManager(org.apache.maven.profiles.ProfileManager) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) PlexusContainerException(org.codehaus.plexus.PlexusContainerException) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) FileNotFoundException(java.io.FileNotFoundException) ModelInterpolationException(org.apache.maven.project.interpolation.ModelInterpolationException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) SecDispatcherException(org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException) IOException(java.io.IOException) Artifact(org.apache.maven.artifact.Artifact) ProjectBuilderConfiguration(org.apache.maven.project.ProjectBuilderConfiguration) MavenProjectBuilder(org.apache.maven.project.MavenProjectBuilder) MavenProject(org.apache.maven.project.MavenProject) File(java.io.File) ArtifactMetadataSource(org.apache.maven.artifact.metadata.ArtifactMetadataSource) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ProjectBuilderConfiguration (org.apache.maven.project.ProjectBuilderConfiguration)2 ModelInterpolationException (org.apache.maven.project.interpolation.ModelInterpolationException)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Date (java.util.Date)1 Properties (java.util.Properties)1 Artifact (org.apache.maven.artifact.Artifact)1 ArtifactMetadataSource (org.apache.maven.artifact.metadata.ArtifactMetadataSource)1 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)1 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)1 DefaultProfileManager (org.apache.maven.profiles.DefaultProfileManager)1 ProfileManager (org.apache.maven.profiles.ProfileManager)1 DefaultProjectBuilderConfiguration (org.apache.maven.project.DefaultProjectBuilderConfiguration)1 MavenProject (org.apache.maven.project.MavenProject)1 MavenProjectBuilder (org.apache.maven.project.MavenProjectBuilder)1 AbstractStringBasedModelInterpolator (org.apache.maven.project.interpolation.AbstractStringBasedModelInterpolator)1 DefaultPathTranslator (org.apache.maven.project.path.DefaultPathTranslator)1 PlexusContainerException (org.codehaus.plexus.PlexusContainerException)1