Java Code Examples for org.apache.maven.project.MavenProject

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project build-info, under directory /build-info-extractor-maven3/src/main/java/org/jfrog/build/extractor/maven/.

Source file: BuildInfoRecorder.java

  24 
vote

@Override public void projectStarted(ExecutionEvent event){
  MavenProject project=event.getProject();
  initModule(project);
  if (wrappedListener != null) {
    wrappedListener.projectStarted(event);
  }
}
 

Example 2

From project clirr-maven-plugin, under directory /src/main/java/org/codehaus/mojo/clirr/.

Source file: AbstractClirrMojo.java

  23 
vote

protected List getTransitiveDependencies(final Set previousArtifacts) throws ProjectBuildingException, InvalidDependencyVersionException, ArtifactResolutionException, ArtifactNotFoundException {
  final List dependencies=new ArrayList();
  for (Iterator iter=previousArtifacts.iterator(); iter.hasNext(); ) {
    final Artifact a=(Artifact)iter.next();
    final Artifact pomArtifact=factory.createArtifact(a.getGroupId(),a.getArtifactId(),a.getVersion(),a.getScope(),"pom");
    final MavenProject pomProject=mavenProjectBuilder.buildFromRepository(pomArtifact,project.getRemoteArtifactRepositories(),localRepository);
    final Set pomProjectArtifacts=pomProject.createArtifacts(factory,null,null);
    final ArtifactResolutionResult result=resolver.resolveTransitively(pomProjectArtifacts,pomArtifact,localRepository,project.getRemoteArtifactRepositories(),metadataSource,null);
    dependencies.addAll(result.getArtifacts());
  }
  return dependencies;
}
 

Example 3

From project flexmojos, under directory /flexmojos-maven-plugin/src/main/java/net/flexmojos/oss/plugin/war/.

Source file: CopyMojo.java

  22 
vote

private void performSubArtifactsCopy(Artifact artifact) throws MojoExecutionException {
  MavenProject artifactProject=getProject(artifact);
  if (artifactProject != null) {
    if (copyRSL) {
      performRslCopy(artifactProject);
    }
    if (copyRuntimeLocales) {
      performRuntimeLocalesCopy(artifactProject);
    }
  }
}
 

Example 4

From project grails-maven, under directory /src/test/java/org/grails/maven/plugin/tools/.

Source file: GrailsServicesTest.java

  22 
vote

public void testPomIsValid() throws Exception {
  ModelValidator modelValidator=(ModelValidator)lookup(ModelValidator.class.getName());
  GrailsServices grailsServices=(GrailsServices)lookup(GrailsServices.class.getName());
  grailsServices.setBasedir(getTestFile(""));
  MavenProject pom=grailsServices.createPOM("a.group",grailsDescriptorTest,"org.grails","grails-maven-plugin","1.0");
  assertEquals(0,modelValidator.validate(pom.getModel()).getMessageCount());
  release(modelValidator);
  release(grailsServices);
}
 

Example 5

From project gwt-maven-plugin, under directory /src/main/java/org/codehaus/mojo/gwt/.

Source file: ClasspathBuilder.java

  22 
vote

/** 
 * Add all sources and resources also with active (maven reactor active) referenced project sources and resources.
 * @param project
 * @param items
 * @param scope
 */
public void addSourcesWithActiveProjects(final MavenProject project,final Collection<File> items,final String scope){
  final List<Artifact> scopeArtifacts=getScopeArtifacts(project,scope);
  addSources(items,getSourceRoots(project,scope));
  for (  Artifact artifact : scopeArtifacts) {
    String projectReferenceId=getProjectReferenceId(artifact.getGroupId(),artifact.getArtifactId(),artifact.getVersion());
    MavenProject refProject=(MavenProject)project.getProjectReferences().get(projectReferenceId);
    if (refProject != null) {
      addSources(items,getSourceRoots(refProject,scope));
    }
  }
}
 

Example 6

From project hbc-maven-core, under directory /src/main/java/org/hardisonbrewing/maven/core/.

Source file: DependencyService.java

  22 
vote

/** 
 * Copy all  {@link Dependency} {@link Artifact}s to the specified destination directory.
 * @param dest The destination directory.
 * @throws Exception
 */
public static final void copyDependencies(File dest) throws Exception {
  MavenProject mavenProject=ProjectService.getProject();
  Set<Artifact> artifacts=mavenProject.getDependencyArtifacts();
  Iterator<Artifact> iterator=artifacts.iterator();
  while (iterator.hasNext()) {
    Artifact artifact=iterator.next();
    FileUtils.copyFileToDirectory(artifact.getFile(),dest);
  }
}
 

Example 7

From project jangaroo-tools, under directory /jangaroo-maven/jangaroo-maven-plugin/src/main/java/net/jangaroo/jooc/mvnplugin/.

Source file: PackageApplicationMojo.java

  22 
vote

private List<String> getDependencies(Artifact artifact) throws ProjectBuildingException {
  MavenProject mp=mavenProjectBuilder.buildFromRepository(artifact,remoteRepositories,localRepository,true);
  List<String> deps=new LinkedList<String>();
  for (  Dependency dep : getDependencies(mp)) {
    if ("jar".equals(dep.getType()) && (dep.getScope().equals("compile") || dep.getScope().equals("runtime"))) {
      deps.add(getInternalId(dep));
    }
  }
  return deps;
}
 

Example 8

From project lib-jenkins-maven-embedder, under directory /src/main/java/hudson/maven/.

Source file: MavenEmbedder.java

  22 
vote

public List<MavenProject> collectProjects(File basedir,String[] includes,String[] excludes) throws MojoExecutionException, MavenEmbedderException {
  List<MavenProject> projects=new ArrayList<MavenProject>();
  List<File> poms=getPomFiles(basedir,includes,excludes);
  for (  File pom : poms) {
    try {
      MavenProject p=readProject(pom);
      projects.add(p);
    }
 catch (    ProjectBuildingException e) {
      throw new MojoExecutionException("Error loading " + pom,e);
    }
  }
  return projects;
}
 

Example 9

From project m2e-android, under directory /me.gladwell.eclipse.m2e.android/src/main/java/me/gladwell/eclipse/m2e/android/project/.

Source file: MavenToEclipseAndroidProjectConverter.java

  22 
vote

public MavenAndroidProject createAndroidProject(EclipseAndroidProject androidProject){
  Model model;
  try {
    model=mavenModelManager.readMavenModel(androidProject.getPom());
  }
 catch (  CoreException e) {
    throw new ProjectConfigurationException(e);
  }
  MavenProject project=new MavenProject(model);
  return mavenProjectFactory.createAndroidProject(project);
}
 

Example 10

From project m2e-code-quality, under directory /com.basistech.m2e.code.quality.shared/src/main/java/com/basistech/m2e/code/quality/shared/.

Source file: AbstractMavenPluginProjectConfigurator.java

  22 
vote

@Override public void configure(final ProjectConfigurationRequest request,final IProgressMonitor monitor) throws CoreException {
  final MavenProject mavenProject=request.getMavenProject();
  if (mavenProject == null) {
    return;
  }
  final MavenPluginWrapper pluginWrapper=this.getMavenPlugin(monitor,request.getMavenProjectFacade());
  final IProject project=request.getProject();
  if (!pluginWrapper.isPluginConfigured()) {
    return;
  }
  this.handleProjectConfigurationChange(request.getMavenSession(),request.getMavenProjectFacade(),project,monitor,pluginWrapper);
}
 

Example 11

From project m2e-core-tests, under directory /org.eclipse.m2e.editor.tests/src/org/eclipse/m2e/editor/dialogs/.

Source file: ManageDependenciesDialogTest.java

  22 
vote

protected MavenProject getMavenProject(String groupID,String artifactID,String version){
  IMavenProjectRegistry mavenProjectManager=MavenPlugin.getMavenProjectRegistry();
  assertNotNull(mavenProjectManager);
  IMavenProjectFacade facade=mavenProjectManager.getMavenProject(groupID,artifactID,version);
  assertNotNull(facade);
  MavenProject project=facade.getMavenProject();
  assertNotNull(project);
  return project;
}
 

Example 12

From project cargo-maven2-plugin-db, under directory /src/main/java/org/codehaus/cargo/maven2/.

Source file: DependencyCalculator.java

  21 
vote

public Set execute() throws ArtifactResolutionException, ArtifactNotFoundException, ProjectBuildingException, FileNotFoundException, IOException, XmlPullParserException, InvalidDependencyVersionException, ArtifactInstallationException {
  ProfileManager profileManager=new DefaultProfileManager(container);
  fixupProjectArtifact();
  Artifact art=mavenProject.getArtifact();
  Artifact art2=artifactFactory.createArtifactWithClassifier(art.getGroupId() + ".cargodeps",art.getArtifactId(),art.getVersion(),"pom",null);
  resolver.resolve(art2,remoteRepositories,localRepository);
  MavenProject mavenProject=mavenProjectBuilder.buildWithDependencies(art2.getFile(),localRepository,profileManager);
  Set filesToAdd=new HashSet();
  for (Iterator i=mavenProject.getArtifacts().iterator(); i.hasNext(); ) {
    Artifact artdep=(Artifact)i.next();
    if (artdep.getType().equals("jar")) {
      resolver.resolve(artdep,remoteRepositories,localRepository);
      filesToAdd.add(artdep.getFile());
    }
  }
  return filesToAdd;
}
 

Example 13

From project ftpserver-maven-plugin, under directory /src/test/java/cat/calidos/maven/ftpserver/.

Source file: FtpServerMojoTest.java

  21 
vote

/** 
 * Run stop server mojo
 * @throws java.lang.Exception
 */
public void tearDown() throws Exception {
  if (ftp.isAvailable()) {
    if (ftp.isConnected()) {
      ftp.disconnect();
    }
  }
  FtpServerStopMojo stopMojo=(FtpServerStopMojo)lookupMojo("stop",pom);
  Properties properties=new Properties();
  properties.put(FtpServerConstants.FTPSERVER_KEY,ftpServer);
  stopMojo.mavenProject=new MavenProject();
  stopMojo.mavenProject.getModel().setProperties(properties);
  stopMojo.execute();
  super.tearDown();
}
 

Example 14

From project jetty-maven-plugin, under directory /src/main/java/org/mortbay/jetty/plugin/.

Source file: RuntimeDependencyResolver.java

  21 
vote

/** 
 * Download (if necessary) a pom, and load it as a MavenProject, transitively resolving any dependencies therein.
 * @param projectBuilder
 * @param groupId
 * @param artifactId
 * @param versionId
 * @return a Set of Artifacts representing the transitively resolved dependencies.
 * @throws MalformedURLException
 * @throws ProjectBuildingException
 * @throws InvalidDependencyVersionException
 * @throws ArtifactResolutionException
 * @throws ArtifactNotFoundException
 */
public Set transitivelyResolvePomDependencies(MavenProjectBuilder projectBuilder,String groupId,String artifactId,String versionId,boolean resolveProjectArtifact) throws MalformedURLException, ProjectBuildingException, InvalidDependencyVersionException, ArtifactResolutionException, ArtifactNotFoundException {
  Artifact pomArtifact=getPomArtifact(groupId,artifactId,versionId);
  MavenProject project=loadPomAsProject(projectBuilder,pomArtifact);
  List dependencies=project.getDependencies();
  Set dependencyArtifacts=MavenMetadataSource.createArtifacts(artifactFactory,dependencies,null,null,null);
  dependencyArtifacts.add(project.getArtifact());
  List listeners=Collections.EMPTY_LIST;
  if (PluginLog.getLog().isDebugEnabled()) {
    listeners=new ArrayList();
    listeners.add(new RuntimeResolutionListener());
  }
  ArtifactResolutionResult result=artifactResolver.resolveTransitively(dependencyArtifacts,pomArtifact,Collections.EMPTY_MAP,localRepository,remoteRepositories,metadataSource,null,listeners);
  Set artifacts=result.getArtifacts();
  if (PluginLog.getLog().isDebugEnabled()) {
    PluginLog.getLog().debug("RESOLVED " + artifacts.size() + " ARTIFACTS");
    Iterator itor=artifacts.iterator();
    while (itor.hasNext()) {
      Artifact a=(Artifact)itor.next();
      PluginLog.getLog().debug(a.getFile().toURL().toString());
    }
  }
  return artifacts;
}
 

Example 15

From project legacy-maven-support, under directory /maven-plugin/src/main/java/hudson/maven/.

Source file: Maven3Builder.java

  21 
vote

public void reccordProjectStarted(ExecutionEvent event){
  MavenProject mavenProject=event.getProject();
  List<MavenReporter> mavenReporters=getMavenReporters(mavenProject);
  MavenBuildProxy2 mavenBuildProxy2=getMavenBuildProxy2(mavenProject);
  mavenBuildProxy2.start();
  if (mavenReporters != null) {
    for (    MavenReporter mavenReporter : mavenReporters) {
      try {
        mavenReporter.enterModule(mavenBuildProxy2,mavenProject,maven3Builder.listener);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
catch (      IOException e) {
        e.printStackTrace();
      }
    }
  }
  if (mavenReporters != null) {
    for (    MavenReporter mavenReporter : mavenReporters) {
      try {
        mavenReporter.preBuild(mavenBuildProxy2,mavenProject,maven3Builder.listener);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
catch (      IOException e) {
        e.printStackTrace();
      }
    }
  }
}
 

Example 16

From project license-maven-plugin, under directory /src/main/java/org/codehaus/mojo/license/.

Source file: AggregatorAddThirdPartyMojo.java

  21 
vote

@Override protected SortedProperties createUnsafeMapping() throws ProjectBuildingException, IOException {
  String path=getMissingFile().getAbsolutePath().substring(getProject().getBasedir().getAbsolutePath().length() + 1);
  if (isVerbose()) {
    getLog().info("Use missing file path : " + path);
  }
  SortedProperties unsafeMappings=new SortedProperties(getEncoding());
  LicenseMap licenseMap=getLicenseMap();
  for (  Object o : reactorProjects) {
    MavenProject p=(MavenProject)o;
    File file=new File(p.getBasedir(),path);
    if (file.exists()) {
      SortedProperties tmp=getThridPartyTool().loadUnsafeMapping(licenseMap,getArtifactCache(),getEncoding(),file);
      unsafeMappings.putAll(tmp);
    }
    SortedSet<MavenProject> unsafes=getThridPartyTool().getProjectsWithNoLicense(licenseMap,isVerbose());
    if (CollectionUtils.isEmpty(unsafes)) {
      break;
    }
  }
  return unsafeMappings;
}
 

Example 17

From project liferay-maven-support, under directory /plugins/liferay-maven-plugin/src/main/java/com/liferay/maven/plugins/.

Source file: AbstractLiferayMojo.java

  21 
vote

protected void copyLibraryDependencies(File libDir,Artifact artifact,boolean dependencyAddVersion,boolean dependencyAddClassifier,boolean copyTransitive) throws Exception {
  MavenProject mavenProject=resolveProject(artifact);
  List<Dependency> dependencies=mavenProject.getDependencies();
  for (  Dependency dependency : dependencies) {
    String scope=dependency.getScope();
    if (Validator.isNotNull(scope) && (scope.equalsIgnoreCase("provided") || scope.equalsIgnoreCase("test"))) {
      continue;
    }
    String type=dependency.getType();
    if (type.equalsIgnoreCase("pom")) {
      continue;
    }
    Artifact libArtifact=resolveArtifact(dependency);
    String libJarFileName=libArtifact.getArtifactId();
    if (dependencyAddVersion) {
      if (Validator.isNotNull(libArtifact.getVersion())) {
        libJarFileName+="-" + libArtifact.getVersion();
      }
    }
    if (dependencyAddClassifier) {
      if (Validator.isNotNull(libArtifact.getClassifier())) {
        libJarFileName+="-" + libArtifact.getClassifier();
      }
    }
    File libArtifactFile=libArtifact.getFile();
    libJarFileName+="." + FileUtil.getExtension(libArtifactFile.getName());
    CopyTask.copyFile(libArtifactFile,libDir,libJarFileName,null,true,true);
    if (copyTransitive) {
      copyLibraryDependencies(libDir,libArtifact,dependencyAddVersion,dependencyAddClassifier,copyTransitive);
    }
  }
}
 

Example 18

From project m2e-apt, under directory /org.jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/.

Source file: AbstractAptConfiguratorDelegate.java

  21 
vote

public void configureClasspath(IClasspathDescriptor classpath,IProgressMonitor monitor) throws CoreException {
  AnnotationProcessorConfiguration configuration=getAnnotationProcessorConfiguration(monitor);
  if (configuration == null || !configuration.isAnnotationProcessingEnabled()) {
    return;
  }
  File generatedSourcesDirectory=configuration.getOutputDirectory();
  MavenProject mavenProject=mavenFacade.getMavenProject();
  IProject eclipseProject=mavenFacade.getProject();
  if (generatedSourcesDirectory != null && generatedSourcesDirectory.exists()) {
    File outputFolder=new File(mavenProject.getBuild().getOutputDirectory());
    addToClassPath(eclipseProject,generatedSourcesDirectory,outputFolder,classpath);
  }
  File generatedTestSourcesDirectory=configuration.getTestOutputDirectory();
  if (generatedTestSourcesDirectory != null && generatedTestSourcesDirectory.exists()) {
    File outputFolder=new File(mavenProject.getBuild().getTestOutputDirectory());
    addToClassPath(eclipseProject,generatedTestSourcesDirectory,outputFolder,classpath);
  }
}
 

Example 19

From project m2eclipse-extras, under directory /org.sonatype.m2e.mavenarchiver/src/org/sonatype/m2e/mavenarchiver/internal/.

Source file: AbstractMavenArchiverConfigurator.java

  21 
vote

/** 
 * Checks if the MANIFEST.MF needs to be regenerated. That is if : <ul><li>it doesn't already exist</li> <li>the maven project configuration changed</li> <li>the maven project dependencies changed</li> </ul>  Implementations can override this method to add pre-conditions.
 * @param manifest the MANIFEST.MF file to control
 * @param oldFacade the old maven facade project configuration
 * @param newFacade the new maven facade project configuration
 * @param monitor the progress monitor
 * @return true if the MANIFEST.MF needs to be regenerated
 */
protected boolean needsNewManifest(IFile manifest,IMavenProjectFacade oldFacade,IMavenProjectFacade newFacade,IProgressMonitor monitor){
  if (!manifest.exists()) {
    return true;
  }
  if (oldFacade == null || oldFacade.getMavenProject() == null) {
    return false;
  }
  MavenProject newProject=newFacade.getMavenProject();
  MavenProject oldProject=oldFacade.getMavenProject();
  if (dependenciesChanged(oldProject.getArtifacts() == null ? null : new ArrayList<Artifact>(oldProject.getArtifacts()),newProject.getArtifacts() == null ? null : new ArrayList<Artifact>(newProject.getArtifacts()))) {
    return true;
  }
  Xpp3Dom oldArchiveConfig=getArchiveConfiguration(oldProject);
  Xpp3Dom newArchiveConfig=getArchiveConfiguration(newProject);
  if (newArchiveConfig != null && !newArchiveConfig.equals(oldArchiveConfig) || oldArchiveConfig != null) {
    return true;
  }
  if (!newProject.getName().equals(oldProject.getName())) {
    return true;
  }
  String oldOrganizationName=oldProject.getOrganization() == null ? null : oldProject.getOrganization().getName();
  String newOrganizationName=newProject.getOrganization() == null ? null : newProject.getOrganization().getName();
  if (newOrganizationName != null && !newOrganizationName.equals(oldOrganizationName) || oldOrganizationName != null && newOrganizationName == null) {
    return true;
  }
  return false;
}
 

Example 20

From project jADT, under directory /jADT-maven/src/test/java/com/pogofish/jadt/maven/.

Source file: JADTMojoTest.java

  20 
vote

/** 
 * Make sure that everything works on the happy path
 */
@Test public void testHappy() throws Exception {
  final File srcFile=new File(JADT.TEST_SRC_INFO);
  final File destDir=new File(JADT.TEST_DIR);
  final JADTMojo mojo=new JADTMojo();
  final StringSinkFactoryFactory factory=new StringSinkFactoryFactory();
  mojo.jadt=JADT.createDummyJADT(Collections.<SyntaxError>emptyList(),Collections.<SemanticError>emptyList(),srcFile.getCanonicalPath(),factory);
  mojo.setSrcPath(srcFile);
  mojo.setDestDir(destDir);
  mojo.setProject(new MavenProject());
  mojo.execute();
  final String result=factory.results().get(destDir.getCanonicalPath()).get(0).getResults().get(JADT.TEST_CLASS_NAME);
  assertEquals(JADT.TEST_SRC_INFO,result);
  assertEquals(1,mojo.project.getCompileSourceRoots().size());
  assertEquals(destDir.getCanonicalPath(),mojo.project.getCompileSourceRoots().get(0));
}
 

Example 21

From project artifactory-plugin, under directory /src/main/java/org/jfrog/hudson/maven2/.

Source file: MavenDependenciesRecorder.java

  19 
vote

/** 
 * Sends the collected dependencies over to the master and record them.
 */
@Override public boolean postBuild(MavenBuildProxy build,MavenProject pom,BuildListener listener) throws InterruptedException, IOException {
  build.executeAsync(new BuildCallable<Void,IOException>(){
    private final Set<MavenDependency> d=dependencies;
    public Void call(    MavenBuild build) throws IOException, InterruptedException {
      build.getActions().add(new MavenDependenciesRecord(build,d));
      return null;
    }
  }
);
  return true;
}
 

Example 22

From project blacktie, under directory /utils/cpp-plugin/src/main/java/org/jboss/narayana/blacktie/plugins/.

Source file: AddCommonSources.java

  19 
vote

private void processResources(MavenProject p){
  List resources=p.getResources();
  if (resources != null) {
    for (Iterator i=resources.iterator(); i.hasNext(); ) {
      Resource resource=(Resource)i.next();
      String resourceRoot=resource.getDirectory();
      unzip(getClass().getResourceAsStream("/cxx.jar"),outputDir,includes);
      p.addTestCompileSourceRoot(outputDir);
    }
  }
}
 

Example 23

From project cdk, under directory /maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/.

Source file: AbstractCDKMojo.java

  19 
vote

protected ClassLoader createProjectClassLoader(MavenProject project,boolean useCCL){
  ClassLoader classLoader=Thread.currentThread().getContextClassLoader();
  try {
    List<?> compileClasspathElements=project.getCompileClasspathElements();
    String outputDirectory=project.getBuild().getOutputDirectory();
    URL[] urls=new URL[compileClasspathElements.size() + 1];
    int i=0;
    urls[i++]=new File(outputDirectory).toURI().toURL();
    for (Iterator<?> iter=compileClasspathElements.iterator(); iter.hasNext(); ) {
      String element=(String)iter.next();
      urls[i++]=new File(element).toURI().toURL();
    }
    if (useCCL) {
      classLoader=new URLClassLoader(urls,classLoader);
    }
 else {
      classLoader=new URLClassLoader(urls);
    }
  }
 catch (  MalformedURLException e) {
    getLog().error("Bad URL in classpath",e);
  }
catch (  DependencyResolutionRequiredException e) {
    getLog().error("Dependencies not resolved ",e);
  }
  return classLoader;
}
 

Example 24

From project cloudbees-deployer-plugin, under directory /src/main/java/org/jenkins/plugins/cloudbees/.

Source file: MavenArtifactFilePathSaver.java

  19 
vote

public boolean postBuild(MavenBuildProxy build,MavenProject pom,final BuildListener listener) throws InterruptedException, IOException {
  listener.getLogger().println("post build " + (pom.getArtifact() != null) + ":"+ (pom.getAttachedArtifacts() != null));
  if (pom != null && pom.getArtifact() != null || pom.getAttachedArtifacts() != null) {
    final Set<MavenArtifactWithFilePath> mavenArtifacts=new HashSet<MavenArtifactWithFilePath>();
    if (pom.getArtifact() != null) {
      final MavenArtifact mainArtifact=MavenArtifact.create(pom.getArtifact());
      if (mainArtifact != null && pom.getArtifact() != null && pom.getArtifact().getFile() != null) {
        mavenArtifacts.add(new MavenArtifactWithFilePath(pom.getGroupId(),pom.getArtifactId(),pom.getVersion(),pom.getArtifact().getFile().getPath(),pom.getArtifact().getType()));
      }
    }
    if (pom.getAttachedArtifacts() != null) {
      final List<MavenArtifact> attachedArtifacts=new ArrayList<MavenArtifact>();
      for (      Artifact a : pom.getAttachedArtifacts()) {
        MavenArtifact ma=MavenArtifact.create(a);
        if (ma != null && pom.getArtifact() != null && pom.getArtifact().getFile() != null) {
          mavenArtifacts.add(new MavenArtifactWithFilePath(pom.getGroupId(),pom.getArtifactId(),pom.getVersion(),pom.getArtifact().getFile().getPath(),pom.getArtifact().getType()));
        }
      }
    }
    build.execute(new MavenBuildProxy.BuildCallable<Void,IOException>(){
      public Void call(      MavenBuild build) throws IOException, InterruptedException {
        ArtifactFilePathSaveAction artifactFilePathSaveAction=build.getAction(ArtifactFilePathSaveAction.class);
        if (artifactFilePathSaveAction == null) {
          artifactFilePathSaveAction=new ArtifactFilePathSaveAction(mavenArtifacts);
        }
 else {
          artifactFilePathSaveAction.mavenArtifactWithFilePaths.addAll(mavenArtifacts);
        }
        build.addAction(artifactFilePathSaveAction);
        build.save();
        return null;
      }
    }
);
  }
  return true;
}
 

Example 25

From project cpp-maven-plugins, under directory /cpp-compiler-maven-plugin/src/main/java/com/ericsson/tools/cpp/compiler/artifacts/.

Source file: ArtifactManager.java

  19 
vote

@SuppressWarnings("unchecked") public ArtifactManager(final Log log,final MavenProject project,final ArtifactFactory factory,final ArtifactResolver resolver,final ArtifactRepository localRepository,final List remoteRepositories){
  this.factory=factory;
  this.resolver=resolver;
  this.localRepository=localRepository;
  this.remoteRepositories=remoteRepositories;
  this.carDependencies=new ArtifactFilter(log,"car").filter(project.getArtifacts());
}
 

Example 26

From project jboss-as-maven-plugin, under directory /src/main/java/org/jboss/as/plugin/deployment/.

Source file: PackageType.java

  19 
vote

/** 
 * Resolves the package type from the maven project.
 * @param project the maven project
 * @return the package type
 */
public static PackageType resolve(final MavenProject project){
  final String packaging=project.getPackaging();
  if (DEFAULT_TYPES.containsKey(packaging)) {
    return DEFAULT_TYPES.get(packaging);
  }
  return new PackageType(packaging);
}
 

Example 27

From project jdeb, under directory /src/main/java/org/vafer/jdeb/maven/.

Source file: AbstractPluginMojo.java

  19 
vote

protected MavenProject getProject(){
  if (project.getExecutionProject() != null) {
    return project.getExecutionProject();
  }
  return project;
}
 

Example 28

From project karaf, under directory /tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/.

Source file: DependencyHelper.java

  19 
vote

public void getDependencies(MavenProject project,boolean useTransitiveDependencies) throws MojoExecutionException {
  DependencyNode rootNode=getDependencyTree(RepositoryUtils.toArtifact(project.getArtifact()));
  Scanner scanner=new Scanner();
  scanner.scan(rootNode,useTransitiveDependencies);
  localDependencies=scanner.localDependencies;
  treeListing=scanner.getLog();
}
 

Example 29

From project liquibase, under directory /liquibase-maven-plugin/src/main/java/org/liquibase/maven/plugins/.

Source file: MavenUtils.java

  19 
vote

/** 
 * Obtains a  {@link ClassLoader} that can load from the Maven project dependencies. Ifthe dependencies have not be resolved (or there are none) then this will just end up delegating to the parent  {@link ClassLoader} of this class.
 * @return The ClassLoader that can load the resolved dependencies for the Mavenproject.
 * @throws java.net.MalformedURLException If any of the dependencies cannot be resolvedinto a URL.
 */
public static ClassLoader getArtifactClassloader(MavenProject project,boolean includeArtifact,boolean includeTestOutputDirectory,Class clazz,Log log,boolean verbose) throws MalformedURLException {
  if (verbose) {
    log.info("Loading artfacts into URLClassLoader");
  }
  Set<URL> urls=new HashSet<URL>();
  Set dependencies=project.getDependencyArtifacts();
  if (dependencies != null && !dependencies.isEmpty()) {
    for (Iterator it=dependencies.iterator(); it.hasNext(); ) {
      addArtifact(urls,(Artifact)it.next(),log,verbose);
    }
  }
 else {
    log.info("there are no resolved artifacts for the Maven project.");
  }
  if (includeArtifact) {
    Artifact a=project.getArtifact();
    if (a.getFile() != null) {
      addArtifact(urls,a,log,verbose);
    }
 else {
      addFile(urls,new File(project.getBuild().getOutputDirectory()),log,verbose);
    }
  }
  if (includeTestOutputDirectory) {
    addFile(urls,new File(project.getBuild().getTestOutputDirectory()),log,verbose);
  }
  if (verbose) {
    log.info(LOG_SEPARATOR);
  }
  URL[] urlArray=urls.toArray(new URL[urls.size()]);
  return new URLClassLoader(urlArray,clazz.getClassLoader());
}