org.apache.maven.project.MavenProjectBuilder Java Examples
The following examples show how to use
org.apache.maven.project.MavenProjectBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DependenciesRenderer.java From maven-confluence-plugin with Apache License 2.0 | 6 votes |
/** * * @param sink * @param project * @param mavenProjectBuilder * @param locale * @param listener */ public DependenciesRenderer( Sink sink, MavenProject project, MavenProjectBuilder mavenProjectBuilder, ArtifactRepository localRepository, ArtifactFactory factory, I18N i18n, Locale locale, ReportingResolutionListener listener, Log log ) { super( sink ); this.project = project; this.locale = locale; this.listener = listener; this.mavenProjectBuilder = mavenProjectBuilder; this.localRepository = localRepository; this.i18n = i18n; this.factory = factory; this.log = log; }
Example #2
Source File: AbstractJnlpMojoTest.java From webstart with MIT License | 6 votes |
private void setUpProject( File pomFile, AbstractMojo mojo ) throws Exception { MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( true, "never", "never" ); String localRepoUrl = "file://" + System.getProperty( "user.home" ) + "/.m2/repository"; ArtifactRepository localRepository = artifactRepositoryFactory.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), policy, policy ); ProfileManager profileManager = new DefaultProfileManager( getContainer() ); MavenProject project = projectBuilder.buildWithDependencies( pomFile, localRepository, profileManager ); //this gets the classes for these tests of this mojo (exec plugin) onto the project classpath for the test project.getBuild().setOutputDirectory( new File( "target/test-classes" ).getAbsolutePath() ); setVariableValueToObject( mojo, "project", project ); }
Example #3
Source File: PluginsRenderer.java From maven-confluence-plugin with Apache License 2.0 | 5 votes |
/** * @param log * @param sink * @param locale * @param i18n * @param plugins * @param reports * @param project * @param mavenProjectBuilder * @param artifactFactory * @param localRepository */ public PluginsRenderer( Log log, Sink sink, Locale locale, I18N i18n, Set<Artifact> plugins, Set<Artifact> reports, MavenProject project, MavenProjectBuilder mavenProjectBuilder, ArtifactFactory artifactFactory, ArtifactRepository localRepository ) { super( sink ); this.log = log; this.locale = locale; this.plugins = new ArrayList<>( plugins ); this.reports = new ArrayList<>( reports ); this.i18n = i18n; this.project = project; this.mavenProjectBuilder = mavenProjectBuilder; this.artifactFactory = artifactFactory; this.localRepository = localRepository; }
Example #4
Source File: RunEpisodesBPlugin.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 5 votes |
protected void setUp() throws Exception { super.setUp(); mavenProjectBuilder = (MavenProjectBuilder) getContainer().lookup( MavenProjectBuilder.ROLE); ArtifactFactory artifactFactory = (ArtifactFactory) getContainer() .lookup(ArtifactFactory.ROLE); final Map<String, Mojo> mojos = (Map<String, Mojo>) getContainer() .lookupMap(Mojo.ROLE); for (Mojo mojo : mojos.values()) { if (mojo instanceof Hyperjaxb3Mojo) { this.mojo = (Hyperjaxb3Mojo) mojo; } } MavenSettingsBuilder settingsBuilder = (MavenSettingsBuilder) getContainer() .lookup(MavenSettingsBuilder.ROLE); ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) getContainer() .lookup(ArtifactRepositoryLayout.ROLE, "default"); Settings settings = settingsBuilder.buildSettings(); String url = settings.getLocalRepository(); if (!url.startsWith("file:")) { url = "file://" + url; } localRepository = new DefaultArtifactRepository("local", url, new DefaultRepositoryLayout()); }
Example #5
Source File: RunPoPlugin.java From hyperjaxb3 with BSD 2-Clause "Simplified" License | 4 votes |
protected void setUp() throws Exception { super.setUp(); mavenProjectBuilder = (MavenProjectBuilder) getContainer().lookup( MavenProjectBuilder.ROLE); }
Example #6
Source File: JAXBGenerateTest.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 4 votes |
protected void setUp() throws Exception { super.setUp(); mavenProjectBuilder = (MavenProjectBuilder) getContainer().lookup( MavenProjectBuilder.ROLE); }
Example #7
Source File: JAXBGenerateTest.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 4 votes |
protected void setUp() throws Exception { super.setUp(); mavenProjectBuilder = (MavenProjectBuilder) getContainer().lookup( MavenProjectBuilder.ROLE); }
Example #8
Source File: AbstractXJC2Mojo.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 4 votes |
public MavenProjectBuilder getMavenProjectBuilder() { return mavenProjectBuilder; }
Example #9
Source File: AbstractXJC2Mojo.java From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License | 4 votes |
public void setMavenProjectBuilder(MavenProjectBuilder mavenProjectBuilder) { this.mavenProjectBuilder = mavenProjectBuilder; }
Example #10
Source File: AbstractDaemonGeneratorTest.java From appassembler with MIT License | 2 votes |
public void runTest( String generatorId, String pom, String descriptor, String outputPath ) throws Exception { File outputDir = getTestFile( outputPath ); DaemonGenerator generator = (DaemonGenerator) lookup( DaemonGenerator.ROLE, generatorId ); // ----------------------------------------------------------------------- // Build the MavenProject instance // ----------------------------------------------------------------------- MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE ); MavenSettingsBuilder settingsBuilder = (MavenSettingsBuilder) lookup( MavenSettingsBuilder.ROLE ); Settings settings = settingsBuilder.buildSettings(); ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); String localRepoUrl = new File( settings.getLocalRepository() ).toURL().toExternalForm(); ArtifactRepository localRepository = artifactRepositoryFactory.createDeploymentArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(), false ); ProfileManager profileManager = new DefaultProfileManager( getContainer() ); File tempPom = createFilteredFile( pom ); MavenProject project = projectBuilder.buildWithDependencies( tempPom, localRepository, profileManager ); // ----------------------------------------------------------------------- // Clean the output directory // ----------------------------------------------------------------------- FileUtils.deleteDirectory( outputDir ); FileUtils.forceMkdir( outputDir ); // ----------------------------------------------------------------------- // // ----------------------------------------------------------------------- DaemonGeneratorService daemonGeneratorService = (DaemonGeneratorService) lookup( DaemonGeneratorService.ROLE ); Daemon model = daemonGeneratorService.loadModel( getTestFile( descriptor ) ); generator.generate( new DaemonGenerationRequest( model, project, localRepository, outputDir, "bin" ) ); }