/** * 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(); }
/** * 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 ); } }