本文整理汇总了Java中org.apache.maven.project.MavenProject类的典型用法代码示例。如果您正苦于以下问题:Java MavenProject类的具体用法?Java MavenProject怎么用?Java MavenProject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MavenProject类属于org.apache.maven.project包,在下文中一共展示了MavenProject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToPomForIndexingTmpBundles
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
public void addToPomForIndexingTmpBundles(MavenProject project) throws MavenExecutionException {
Path genertedModules;
try {
genertedModules = Constants.getGeneratedModulesFolder(project);
} catch (IOException e) {
throw new MavenExecutionException(e.getMessage(), e);
}
String configuration = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" //
+ "<configuration>" //
+ " <inputDir>" //
+ genertedModules //
+ " </inputDir>" //
+ " <outputFile>${project.build.directory}/index/index.xml</outputFile>" //
+ "</configuration>"; //
Plugin plugin = createPlugin("biz.aQute.bnd", "bnd-indexer-maven-plugin", VAL_BND_VERSION, configuration,
"index", "local-index", null);
project.getBuild().getPlugins().add(0, plugin);
logger.info("Added `bnd-indexer-maven-plugin` to genrate an index of detected modules!");
}
示例2: extract
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
public String extract() {
Collection<Upload> tasks = project.getTasks().withType(Upload.class);
Collection<ArtifactRepository> repositories = getRepositories(tasks);
if (!onlyContainsMavenResolvers(repositories)) {
return project.getName();
}
Collection<MavenDeployer> deployers = getMavenDeployers(repositories);
Set<String> artifactIds = getArtifactIds(deployers);
if (artifactIds.size() == 1) {
String artifactId = artifactIds.iterator().next();
if (artifactId != null && !artifactId.equals(MavenProject.EMPTY_PROJECT_ARTIFACT_ID)) {
return artifactId;
}
}
String baseName = getArchivesBaseName();
return baseName != null ? baseName : project.getName();
}
示例3: createDependencyTree
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
private static DependencyNode createDependencyTree(MavenProject project,
DependencyTreeBuilder dependencyTreeBuilder, ArtifactRepository localRepository,
ArtifactFactory artifactFactory, ArtifactMetadataSource artifactMetadataSource,
ArtifactCollector artifactCollector,
String scope) {
ArtifactFilter artifactFilter = createResolvingArtifactFilter(scope);
try {
// TODO: note that filter does not get applied due to MNG-3236
return dependencyTreeBuilder.buildDependencyTree(project,
localRepository, artifactFactory,
artifactMetadataSource, artifactFilter, artifactCollector);
} catch (DependencyTreeBuilderException exception) {
}
return null;
}
示例4: touchProject
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
static void touchProject(Project project) {
NbMavenProject prj = project.getLookup().lookup(NbMavenProject.class);
if (prj != null) {
MavenProject mvn = prj.getMavenProject();
if (RunUtils.isCompileOnSaveEnabled(project)) {
touchCoSTimeStamp(mvn, false);
touchCoSTimeStamp(mvn, true);
} else {
File f = getCoSFile(mvn, false);
boolean doClean = f != null && f.exists();
if (doClean) {
try {
cleanGeneratedClassfiles(project);
} catch (IOException ex) {
LOG.log(Level.FINE, "Error cleaning up", ex);
}
}
deleteCoSTimeStamp(mvn, false);
deleteCoSTimeStamp(mvn, true);
}
}
}
示例5: copyYangFilesToTarget
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
/**
* Copies YANG files to the current project's output directory.
*
* @param yangFileInfo list of YANG files
* @param outputDir project's output directory
* @param project maven project
* @throws IOException when fails to copy files to destination resource directory
*/
public static void copyYangFilesToTarget(Set<YangFileInfo> yangFileInfo, String outputDir, MavenProject project)
throws IOException {
List<File> files = getListOfFile(yangFileInfo);
String path = outputDir + TARGET_RESOURCE_PATH;
File targetDir = new File(path);
targetDir.mkdirs();
for (File file : files) {
Files.copy(file.toPath(),
new File(path + file.getName()).toPath(),
StandardCopyOption.REPLACE_EXISTING);
}
addToProjectResource(outputDir + SLASH + TEMP + SLASH, project);
}
示例6: afterProjectsRead
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
@Override
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
Set<String> goals = new HashSet<>(session.getGoals());
if (goals.size() == 1 && goals.contains("clean")) {
logger.info("Eccentric modularity not started (clean only session)! ");
return;
}
// executionListener.setDelegate(session.getRequest().getExecutionListener());
// session.getRequest().setExecutionListener(executionListener);
logger.info("Eccentric modularity extension started!");
List<MavenProject> allProjects = session.getProjects();
for (MavenProject mavenProject : allProjects) {
logger.info("Preparing " + mavenProject);
executionListener.projectStarted(session.getProjectBuildingRequest(), mavenProject);
}
}
示例7: testMissingVersionFromDependencies
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
public void testMissingVersionFromDependencies()
throws MojoExecutionException
{
ArtifactItem item = new ArtifactItem();
item.setArtifactId( "artifactId" );
item.setClassifier( "" );
item.setGroupId( "groupId" );
item.setType( "jar" );
ArrayList list = new ArrayList();
list.add( item );
mojo.setArtifactItems( list );
MavenProject project = mojo.getProject();
project.setDependencies( getDependencyList( item ) );
mojo.execute();
assertMarkerFile( true, item );
assertEquals( "2.0-SNAPSHOT", item.getVersion() );
}
示例8: configureJarPlugin
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
private void configureJarPlugin(MavenProject project) throws MavenExecutionException {
Plugin jarPlugin = getPlugin(project, "org.apache.maven.plugins:maven-jar-plugin");
if (jarPlugin != null) {
StringBuilder jarConfig = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") //
.append("<configuration>") //
.append(" <archive>\n") //
.append(" <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>\n") //
.append(" </archive>") //
.append(" <annotationProcessorPaths>") //
.append(" <annotationProcessorPath>") //
.append(" <groupId>com.commsen.em</groupId>") //
.append(" <artifactId>em.annotation.processors</artifactId>") //
.append(" <version>").append(Constants.VAL_EXTENSION_VERSION).append("</version>") //
.append(" </annotationProcessorPath>") //
.append(" </annotationProcessorPaths>") //
.append("</configuration>");
configurePlugin(jarPlugin, "default-jar", jarConfig.toString());
}
}
示例9: getCompileArtifacts
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
static boolean getCompileArtifacts(MavenProject mavenProject, List<URI> lst) {
// according the current 2.1 sources this is almost the same as getCompileClasspath()
//except for the fact that multiproject references are not redirected to their respective
// output folders.. we lways retrieve stuff from local repo..
List<Artifact> arts = mavenProject.getCompileArtifacts();
boolean broken = false;
for (Artifact art : arts) {
if (art.getFile() != null) {
lst.add(Utilities.toURI(art.getFile()));
broken |= !art.getFile().exists();
} else {
//NOPMD //null means dependencies were not resolved..
broken = true;
}
}
return broken;
}
示例10: load
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
private MavenProject load(ArtifactInfo ai) {
try {
Artifact projectArtifact = embedder.createArtifact(ai.getGroupId(), ai.getArtifactId(), ai.getVersion(), ai.getPackaging() != null ? ai.getPackaging() : "jar");
ProjectBuildingRequest dpbr = embedder.createMavenExecutionRequest().getProjectBuildingRequest();
//mkleint: remote repositories don't matter we use project embedder.
dpbr.setRemoteRepositories(remoteRepos);
dpbr.setProcessPlugins(false);
dpbr.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
ProjectBuildingResult res = embedder.buildProject(projectArtifact, dpbr);
if (res.getProject() != null) {
return res.getProject();
} else {
LOG.log(Level.FINER, "No project model from repository for {0}: {1}", new Object[] {ai, res.getProblems()});
}
} catch (ProjectBuildingException ex) {
LOG.log(Level.FINER, "Failed to load project model from repository for {0}: {1}", new Object[] {ai, ex});
} catch (Exception exception) {
LOG.log(Level.FINER, "Failed to load project model from repository for " + ai, exception);
}
return null;
}
示例11: merge
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
public void merge(
MavenProject project,
Plugin mergePlugin) {
if (mergePlugin.getArtifactId() == null || mergePlugin.getArtifactId().isEmpty()) {
return;
}
List<Plugin> plugins = project.getBuild().getPlugins();
Plugin foundPlugin = null;
for (Plugin plugin : plugins) {
if (mergePlugin.getGroupId().equals(plugin.getGroupId())
&& mergePlugin.getArtifactId().equals(plugin.getArtifactId())) {
foundPlugin = plugin;
break;
}
}
if (foundPlugin == null) {
plugins.add(mergePlugin);
} else {
mergeExecutions(foundPlugin.getExecutions(), mergePlugin.getExecutions());
}
}
示例12: checkChanges
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
@Messages({
"SG_Sources=Source Packages",
"SG_Test_Sources=Test Packages"
})
private void checkChanges(boolean fireChanges, boolean checkAlsoNonJavaStuff) {
boolean changed = false;
synchronized (lock) {
NbMavenProjectImpl project = project();
MavenProject mp = project.getOriginalMavenProject();
NbMavenProject watcher = project.getProjectWatcher();
File folder = FileUtilities.convertStringToFile(mp.getBuild().getSourceDirectory());
changed = changed | checkSourceGroupCache(folder, NAME_SOURCE, SG_Sources(), javaGroup, watcher);
folder = FileUtilities.convertStringToFile(mp.getBuild().getTestSourceDirectory());
changed = changed | checkSourceGroupCache(folder, NAME_TESTSOURCE, SG_Test_Sources(), javaGroup, watcher);
changed = changed | checkGeneratedGroupsCache();
if (checkAlsoNonJavaStuff) {
changed = changed | checkOtherGroupsCache(project.getOtherRoots(false), false);
changed = changed | checkOtherGroupsCache(project.getOtherRoots(true), true);
}
}
if (changed) {
if (fireChanges) {
cs.fireChange();
}
}
}
示例13: checkRunConfig
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
public @Override boolean checkRunConfig(RunConfig config) {
String val = config.getProperties().get(OLD_PROPERTY);
MavenProject prj = config.getMavenProject();
boolean usingNew = usingNbmPlugin311(prj);
if (usingNew) {
if (val == null) {
return true;
}
//modified nbactions.xml file? just adjust to new property
config.setProperty(PROPERTY, val);
config.setProperty(OLD_PROPERTY, null);
return true;
}
if (val == null) { //!usingNew
val = config.getProperties().get(PROPERTY);
if (val == null) {
//using old version of nbm plugin but also not using the old or new property, so it should be save to continue.
return true;
}
config.setProperty(OLD_PROPERTY, val);
}
//offer upgrade to new version.
return removeInterpolation(prj.getFile());
}
示例14: doExecute
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
@Test
public void doExecute() throws Exception {
final PackageMojo mojo = getMojoFromPom();
final PackageMojo mojoSpy = spy(mojo);
ReflectionUtils.setVariableValueInObject(mojoSpy, "finalName", "artifact-0.1.0");
doReturn(mock(AnnotationHandler.class)).when(mojoSpy).getAnnotationHandler();
doReturn(ClasspathHelper.forPackage("com.microsoft.azure.maven.function.handlers").toArray()[0])
.when(mojoSpy)
.getTargetClassUrl();
doReturn("target/azure-functions").when(mojoSpy).getDeploymentStageDirectory();
doReturn("target").when(mojoSpy).getBuildDirectoryAbsolutePath();
doReturn(mock(MavenProject.class)).when(mojoSpy).getProject();
doReturn(mock(MavenSession.class)).when(mojoSpy).getSession();
doReturn(mock(MavenResourcesFiltering.class)).when(mojoSpy).getMavenResourcesFiltering();
mojoSpy.doExecute();
}
示例15: collectSourceRoots
import org.apache.maven.project.MavenProject; //导入依赖的package包/类
private static Set<String> collectSourceRoots(Project prj) {
Set<String> toRet = new HashSet<String>();
NbMavenProject watcher = prj.getLookup().lookup(NbMavenProject.class);
MavenProject mproject = watcher.getMavenProject();
//TODO this ought to be really configurable based on what class gets debugged.
toRet.addAll(mproject.getTestCompileSourceRoots());
//for poms also include all module projects recursively..
boolean isPom = NbMavenProject.TYPE_POM.equals(watcher.getPackagingType());
if (isPom) {
//only for pom is correct use of subprojectprovider
ProjectContainerProvider subs = prj.getLookup().lookup(ProjectContainerProvider.class);
ProjectContainerProvider.Result res = subs.getContainedProjects();
for (Project pr : res.getProjects()) {
toRet.addAll(collectSourceRoots(pr));
}
}
return toRet;
}