List of usage examples for org.apache.maven.project MavenProjectBuilder buildFromRepository
MavenProject buildFromRepository(Artifact artifact, List<ArtifactRepository> remoteRepositories,
ArtifactRepository localRepository) throws ProjectBuildingException;
From source file:com.googlecode.japi.checker.maven.plugin.RuntimeDependencyResolver.java
License:Apache License
public MavenProject loadPomAsProject(MavenProjectBuilder projectBuilder, Artifact pomArtifact) throws ProjectBuildingException { return projectBuilder.buildFromRepository(pomArtifact, remoteRepositories, localRepository); }
From source file:org.hardisonbrewing.maven.core.ProjectService.java
License:Open Source License
/** * Create the {@link MavenProject} for the specified {@link Artifact}. * @param artifact The {@link Artifact} to create the {@link MavenProject} from. * @return/*from w w w.j av a 2 s . c o m*/ * @throws ProjectBuildingException */ public static final MavenProject getProject(Artifact artifact) throws ProjectBuildingException { MavenProjectBuilder mavenProjectBuilder = getProjectBuilder(); return mavenProjectBuilder.buildFromRepository(artifact, DependencyService.getRemoteRepositories(), DependencyService.getLocalRepository()); }
From source file:org.lilyproject.tools.mavenplugin.lilyruntimedepresolver.LilyRuntimeProjectClasspath.java
License:Apache License
public ModuleArtifacts getModuleArtifactsFromLilyRuntimeConfig(Set<Artifact> dependencies, String[] wiringPathPatterns, MavenProjectBuilder mavenProjectBuilder, List remoteRepos) throws MojoExecutionException { ModuleArtifacts result = new ModuleArtifacts(); result.artifacts = new HashSet<Artifact>(); result.remoteRepositories = new ArrayList(); boolean foundAtLeastOneWiring = false; try {//from w w w .ja va 2 s . c om // Search in the jars of all the direct dependencies of the project for the wiring file // (not sure if this won't be too slow? it's just to avoid the user having to specify the artifact) log.info("Searching " + dependencies.size() + " dependencies for " + wiringPathPatterns.length + " path patterns."); for (Artifact artifact : dependencies) { if ("jar".equals(artifact.getType())) { resolver.resolve(artifact, remoteRepos, localRepository); AntPathMatcher matcher = new AntPathMatcher(); ZipFile zipFile; zipFile = new ZipFile(artifact.getFile()); try { Enumeration<? extends ZipEntry> entryEnum = zipFile.entries(); while (entryEnum.hasMoreElements()) { ZipEntry zipEntry = entryEnum.nextElement(); for (String pattern : wiringPathPatterns) { if (matcher.match(pattern, zipEntry.getName())) { foundAtLeastOneWiring = true; log.info("Reading " + zipEntry.getName() + " from " + artifact.getFile()); Set<Artifact> moduleArtifacts = getModuleArtifactsFromLilyRuntimeConfig( zipFile.getInputStream(zipEntry), zipEntry.getName(), remoteRepos); MavenProject wiringSourceProject = mavenProjectBuilder .buildFromRepository(artifact, remoteRepos, localRepository); List repositories = wiringSourceProject.getRemoteArtifactRepositories(); result.artifacts.addAll(moduleArtifacts); result.remoteRepositories.addAll(repositories); } } } } finally { zipFile.close(); } } } } catch (Exception e) { throw new MojoExecutionException("Error searching/reading wiring.xml file from dependency jars.", e); } if (!foundAtLeastOneWiring) { throw new MojoExecutionException("No wiring xml's were found."); } return result; }