com.sun.enterprise.module.maven
Class MavenProjectRepository

java.lang.Object
  extended by com.sun.enterprise.module.common_impl.AbstractRepositoryImpl
      extended by com.sun.enterprise.module.maven.MavenProjectRepository
All Implemented Interfaces:
Repository

public class MavenProjectRepository
extends AbstractRepositoryImpl

Repository implementation that loads modules from the transitive dependencies set in a MavenProject.

Author:
Kohsuke Kawaguchi

Field Summary
 
Fields inherited from class com.sun.enterprise.module.common_impl.AbstractRepositoryImpl
listeners
 
Constructor Summary
MavenProjectRepository(org.apache.maven.project.MavenProject project, org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver, org.apache.maven.artifact.repository.ArtifactRepository localRepository, org.apache.maven.artifact.factory.ArtifactFactory artifactFactory)
           
 
Method Summary
protected  com.sun.enterprise.module.maven.MavenModuleDefinition loadJar(File jar)
          Loads a jar file and builds a ModuleDefinition.
protected  void loadModuleDefs(Map<ModuleId,ModuleDefinition> moduleDefs, List<URI> libraries)
          Called from AbstractRepositoryImpl.initialize() to load all ModuleDefinitions and libraries defintions
static void prepareProject(org.apache.maven.project.MavenProject project)
          When creating MavenProjectRepository from the current project (which is used to launch mvn), and if the compile phase has run yet, then the main artifact is still null.
 
Methods inherited from class com.sun.enterprise.module.common_impl.AbstractRepositoryImpl
add, addLibrary, addListener, find, findAll, findAll, getJarLocations, getLocation, getName, initialize, newModuleDefinition, remove, removeLibrary, removeListener, shutdown, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MavenProjectRepository

public MavenProjectRepository(org.apache.maven.project.MavenProject project,
                              org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver,
                              org.apache.maven.artifact.repository.ArtifactRepository localRepository,
                              org.apache.maven.artifact.factory.ArtifactFactory artifactFactory)
Method Detail

prepareProject

public static void prepareProject(org.apache.maven.project.MavenProject project)
                           throws IOException
When creating MavenProjectRepository from the current project (which is used to launch mvn), and if the compile phase has run yet, then the main artifact is still null.

However, it's often convenient to pick up the files that were left in the file system from the previous execution. This method checks this situation and updates MavenProject accordingly, so that it can be then passed to the constructor of MavenProjectRepository.

Think of this as a pre-processing phase to compensate for the lack of the compile phase invocation.

Throws:
IOException

loadModuleDefs

protected void loadModuleDefs(Map<ModuleId,ModuleDefinition> moduleDefs,
                              List<URI> libraries)
                       throws IOException
Description copied from class: AbstractRepositoryImpl
Called from AbstractRepositoryImpl.initialize() to load all ModuleDefinitions and libraries defintions

Specified by:
loadModuleDefs in class AbstractRepositoryImpl
Throws:
IOException

loadJar

protected com.sun.enterprise.module.maven.MavenModuleDefinition loadJar(File jar)
                                                                 throws IOException
Description copied from class: AbstractRepositoryImpl
Loads a jar file and builds a ModuleDefinition.

The system allows ModuleDefinitions to be built in any way, but in practice module jars need to be built in a way agnostic to Repository implementations (so that same module could be used in different Repositorys), so it makes sense to try to stick to the "common" loading scheme.

Overrides:
loadJar in class AbstractRepositoryImpl
Parameters:
jar - Either a jar file or a directory that has the same structure as a jar file.
Throws:
IOException


Copyright © 2013 Oracle Corporation. All Rights Reserved.