public MavenProject buildFromRepository( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, boolean allowStubModel ) throws ProjectBuildingException { ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration(); configuration.setLocalRepository( localRepository ); return buildFromRepository( artifact, remoteRepositories, configuration, allowStubModel ); }
/** * Serialize the inbound Model instance to a StringWriter, perform the regex replacement to resolve * POM expressions, then re-parse into the resolved Model instance. * <br/> * <b>NOTE:</b> This will result in a different instance of Model being returned!!! * * @param model The inbound Model instance, to serialize and reference for expression resolution * @param context The other context map to be used during resolution * @return The resolved instance of the inbound Model. This is a different instance! * * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration, boolean)} instead. */ public Model interpolate( Model model, Map<String, ?> context, boolean strict ) throws ModelInterpolationException { Properties props = new Properties(); props.putAll( context ); return interpolate( model, null, new DefaultProjectBuilderConfiguration().setExecutionProperties( props ), true ); }
/** * Serialize the inbound Model instance to a StringWriter, perform the regex replacement to resolve * POM expressions, then re-parse into the resolved Model instance. * <p> * <b>NOTE:</b> This will result in a different instance of Model being returned!!! * * @param model The inbound Model instance, to serialize and reference for expression resolution * @param context The other context map to be used during resolution * * @return The resolved instance of the inbound Model. This is a different instance! * * @deprecated Use {@link ModelInterpolator#interpolate(Model, File, ProjectBuilderConfiguration, boolean)} instead. */ public Model interpolate( Model model, Map<String, ?> context, boolean strict ) throws ModelInterpolationException { Properties props = new Properties(); props.putAll( context ); return interpolate( model, null, new DefaultProjectBuilderConfiguration().setExecutionProperties( props ), true ); }
public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStubModel ) throws ProjectBuildingException { String cacheKey = createCacheKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ); MavenProject project = (MavenProject) processedProjectCache.get( cacheKey ); if ( project != null ) { return project; } Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository, allowStubModel ); ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ); return buildInternal( "Artifact [" + artifact + "]", model, config, remoteArtifactRepositories, null, false ); }
public MavenProject build( File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException { ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ).setGlobalProfileManager( profileManager ); return buildFromSourceFileInternal( projectDescriptor, config, true ); }
public MavenProject build( File projectDescriptor, ArtifactRepository localRepository, ProfileManager profileManager, boolean checkDistributionManagementStatus ) throws ProjectBuildingException { ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ).setGlobalProfileManager( profileManager ); return buildFromSourceFileInternal( projectDescriptor, config, checkDistributionManagementStatus ); }
public MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException { return buildStandaloneSuperProject( new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ) .setGlobalProfileManager( profileManager ) ); }
public MavenProject build( File pom, ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException { ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration(); configuration.setLocalRepository( localRepository ); configuration.setGlobalProfileManager( profileManager ); return build( pom, configuration ); }
public MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository, ProfileManager profileManager ) throws ProjectBuildingException { ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration(); configuration.setLocalRepository( localRepository ); configuration.setGlobalProfileManager( profileManager ); return buildStandaloneSuperProject( configuration ); }
superProject = mavenProjectBuilder.buildStandaloneSuperProject( new DefaultProjectBuilderConfiguration() );
public MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository ) throws ProjectBuildingException { //TODO mkleint - use the (Container, Properties) constructor to make system properties embeddable ProfileManager profileManager = new DefaultProfileManager( container ); return buildStandaloneSuperProject( new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository ) .setGlobalProfileManager( profileManager ) ); }
public MavenProject buildWithDependencies( File pom, ArtifactRepository localRepository, ProfileManager profileManager, TransferListener transferListener ) throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException { ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration(); configuration.setLocalRepository( localRepository ); configuration.setGlobalProfileManager( profileManager ); ProjectBuildingRequest request = injectSession( toRequest( configuration ) ); request.setResolveDependencies( true ); try { return projectBuilder.build( pom, request ).getProject(); } catch ( ProjectBuildingException e ) { throw transformError( e ); } }
/** * creates model lineage for the given pom file. * Useful to be able to locate where certain elements are defined. * * @param pom * @param embedder * @param allowStubs * @return */ public static ModelLineage createModelLineage(File pom, MavenEmbedder embedder, boolean allowStubs) throws ProjectBuildingException { try { ModelLineageBuilder bldr = (ModelLineageBuilder) embedder.getPlexusContainer().lookup(ModelLineageBuilder.class); ProfileActivationContext context = new DefaultProfileActivationContext(new Properties(), true); //TODO shall we pass some execution props in here? ProfileManager manager = new DefaultProfileManager(embedder.getPlexusContainer(), context); DefaultProjectBuilderConfiguration conf = new DefaultProjectBuilderConfiguration(); conf.setGlobalProfileManager(manager); conf.setExecutionProperties(new Properties()); conf.setLocalRepository(embedder.getLocalRepository()); conf.setUserProperties(new Properties()); return bldr.buildModelLineage(pom, conf, new ArrayList(), allowStubs, true); } catch (ComponentLookupException ex) { Exceptions.printStackTrace(ex); } return new DefaultModelLineage(); }
/** * creates model lineage for the given pom file. * Useful to be able to locate where certain elements are defined. * * @param pom * @param embedder * @param allowStubs * @return */ public static ModelLineage createModelLineage(File pom, MavenEmbedder embedder, boolean allowStubs) throws ProjectBuildingException { try { ModelLineageBuilder bldr = (ModelLineageBuilder) embedder.getPlexusContainer().lookup(ModelLineageBuilder.class); ProfileActivationContext context = new DefaultProfileActivationContext(new Properties(), true); //TODO shall we pass some execution props in here? ProfileManager manager = new DefaultProfileManager(embedder.getPlexusContainer(), context); DefaultProjectBuilderConfiguration conf = new DefaultProjectBuilderConfiguration(); conf.setGlobalProfileManager(manager); conf.setExecutionProperties(new Properties()); conf.setLocalRepository(embedder.getLocalRepository()); conf.setUserProperties(new Properties()); return bldr.buildModelLineage(pom, conf, new ArrayList(), allowStubs, true); } catch (ComponentLookupException ex) { Exceptions.printStackTrace(ex); } return new DefaultModelLineage(); }
new DefaultProjectBuilderConfiguration().setExecutionProperties( getProject().getProperties() ), false );
new DefaultProjectBuilderConfiguration().setExecutionProperties( getProject().getProperties() ), false );
projectBuilder.buildStandaloneSuperProject( new DefaultProjectBuilderConfiguration() ); superPomPluginManagement.putAll( getPluginManagement( superProject.getOriginalModel() ) );
/** * Create a project builder configuration to be used when initializing the maven project. * * @return */ private ProjectBuilderConfiguration createProjectBuilderConfig( ArtifactRepository localArtifactRepository ) { ProjectBuilderConfiguration builderConfig = new DefaultProjectBuilderConfiguration(); builderConfig.setLocalRepository( localArtifactRepository ); builderConfig.setGlobalProfileManager( this.getActivatedProfiles() ); builderConfig.setUserProperties( getAntProjectProperties() ); builderConfig.setExecutionProperties( getAntProjectProperties() ); return builderConfig; }
/** * Create a minimal project when no POM is available. * * @param localRepository * @return */ protected MavenProject createMinimalProject( ArtifactRepository localRepository ) { MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); DefaultProjectBuilderConfiguration builderConfig = new DefaultProjectBuilderConfiguration( ); builderConfig.setLocalRepository( localRepository ); builderConfig.setGlobalProfileManager( getProfileManager() ); try { MavenProject mavenProject = projectBuilder.buildStandaloneSuperProject(builderConfig); // if we don't null out these fields then the pom that will be created is at the super-pom's // GAV coordinates and we will not be able to inherit partial GAV coordinates from a parent GAV. mavenProject.setGroupId(null); mavenProject.setArtifactId(null); mavenProject.setVersion(null); return mavenProject; } catch ( ProjectBuildingException e ) { throw new BuildException( "Unable to create dummy Pom", e ); } }
/** * Initialize the given mojo. * * @param mojo the instanciate mojo * @param pomFile the pom file used to instanciate the mojo * @throws Exception if any pb */ protected void setUpMojo(P mojo, File pomFile) throws Exception { MavenProject project = mojo.getProject(); if (project == null) { log.debug("init maven project"); MavenProjectBuilder projectBuilder = (MavenProjectBuilder) TestHelper.getDelegateMojoTest().getContainer().lookup( MavenProjectBuilder.ROLE ); ProjectBuilderConfiguration projectBuilderConfiguration = new DefaultProjectBuilderConfiguration(); project = projectBuilder.build(pomFile, projectBuilderConfiguration); // project = new MavenProject(); mojo.setProject(project); } mojo.getProject().setFile(pomFile); }