Package spoon.support.compiler
Class SpoonPom
- java.lang.Object
-
- spoon.support.compiler.SpoonPom
-
- All Implemented Interfaces:
SpoonResource
public class SpoonPom extends Object implements SpoonResource
-
-
Constructor Summary
Constructors Constructor Description SpoonPom(String path, MavenLauncher.SOURCE_TYPE sourceType, Environment environment)
Extract the information from the pomSpoonPom(String path, MavenLauncher.SOURCE_TYPE sourceType, Environment environment, Pattern profileFilter)
Extract the information from the pomSpoonPom(String path, SpoonPom parent, MavenLauncher.SOURCE_TYPE sourceType, Environment environment)
Extract the information from the pomSpoonPom(String path, SpoonPom parent, MavenLauncher.SOURCE_TYPE sourceType, Environment environment, Pattern profileFilter)
Extract the information from the pom
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String[]
buildClassPath(String mvnHome, MavenLauncher.SOURCE_TYPE sourceType, org.slf4j.Logger LOGGER, boolean forceRefresh)
Call maven invoker to generate the classpath.List<File>
getClasspathTmpFiles(String fileName)
Get the list of classpath files generated by mavenFile
getFileSystemParent()
Gets the parent of this resource on the file system.org.apache.maven.model.Model
getModel()
Get the Project Object ModelList<SpoonPom>
getModules()
Get the list of modules defined in this POMString
getName()
Gets the name of this resource.SpoonFolder
getParent()
Get the parent directorySpoonPom
getParentPom()
Get the parent modelString
getPath()
Gets this resource path.List<File>
getSourceDirectories()
Get the list of source directories of the projectint
getSourceVersion()
Get the source version of the projectList<File>
getTestDirectories()
Get the list of test directories of the projectstatic String
guessMavenHome()
Try to guess Maven home when none is provided.boolean
isArchive()
Tells if this resource is an archive.boolean
isFile()
Tells if this resource is a file.File
toFile()
Gets the corresponding file if possible (returns null if this resource does not correspond to any file on the filesystem).String
toString()
-
-
-
Constructor Detail
-
SpoonPom
public SpoonPom(String path, MavenLauncher.SOURCE_TYPE sourceType, Environment environment) throws IOException, org.codehaus.plexus.util.xml.pull.XmlPullParserException
Extract the information from the pom- Parameters:
path
- the path to the pom- Throws:
IOException
- when the file does not existorg.codehaus.plexus.util.xml.pull.XmlPullParserException
- when the file is corrupted
-
SpoonPom
public SpoonPom(String path, MavenLauncher.SOURCE_TYPE sourceType, Environment environment, Pattern profileFilter) throws IOException, org.codehaus.plexus.util.xml.pull.XmlPullParserException
Extract the information from the pom- Parameters:
path
- the path to the pomprofileFilter
- regex pattern to filter profiles when expanding defined modules. Only modules in matching profiles are expanded- Throws:
IOException
- when the file does not existorg.codehaus.plexus.util.xml.pull.XmlPullParserException
- when the file is corrupted
-
SpoonPom
public SpoonPom(String path, SpoonPom parent, MavenLauncher.SOURCE_TYPE sourceType, Environment environment) throws IOException, org.codehaus.plexus.util.xml.pull.XmlPullParserException
Extract the information from the pom- Parameters:
path
- the path to the pomparent
- the parent pom- Throws:
IOException
- when the file does not existorg.codehaus.plexus.util.xml.pull.XmlPullParserException
- when the file is corrupted
-
SpoonPom
public SpoonPom(String path, SpoonPom parent, MavenLauncher.SOURCE_TYPE sourceType, Environment environment, Pattern profileFilter) throws IOException, org.codehaus.plexus.util.xml.pull.XmlPullParserException
Extract the information from the pom- Parameters:
path
- the path to the pomparent
- the parent pomprofileFilter
- regex pattern to filter profiles when expanding defined modules. Only modules in matching profiles are expanded- Throws:
IOException
- when the file does not existorg.codehaus.plexus.util.xml.pull.XmlPullParserException
- when the file is corrupted
-
-
Method Detail
-
getModules
public List<SpoonPom> getModules()
Get the list of modules defined in this POM- Returns:
- the list of modules
-
getModel
public org.apache.maven.model.Model getModel()
Get the Project Object Model- Returns:
- the Project Object Model
-
getSourceDirectories
public List<File> getSourceDirectories()
Get the list of source directories of the project- Returns:
- the list of source directories
-
getTestDirectories
public List<File> getTestDirectories()
Get the list of test directories of the project- Returns:
- the list of test directories
-
getClasspathTmpFiles
public List<File> getClasspathTmpFiles(String fileName)
Get the list of classpath files generated by maven- Returns:
- the list of classpath files
-
getSourceVersion
public int getSourceVersion()
Get the source version of the project- Returns:
- the source version of the project
-
guessMavenHome
public static String guessMavenHome()
Try to guess Maven home when none is provided.- Returns:
- the path toward maven install on the local machine.
- Throws:
SpoonException
- if path to maven executable is wrong, process is interrupted, or maven home could not be found.
-
buildClassPath
public String[] buildClassPath(String mvnHome, MavenLauncher.SOURCE_TYPE sourceType, org.slf4j.Logger LOGGER, boolean forceRefresh)
Call maven invoker to generate the classpath. Either M2_HOME must be initialized, or the command mvn must be in PATH.- Parameters:
mvnHome
- the path to the m2repositorysourceType
- the source type (App, test, or all)LOGGER
- Logger used for maven outputforceRefresh
- if true forces the invocation of maven to regenerate classpath
-
getParentPom
public SpoonPom getParentPom()
Get the parent model- Returns:
- the parent model
-
getParent
public SpoonFolder getParent()
Get the parent directory- Specified by:
getParent
in interfaceSpoonResource
- Returns:
- the parent directory
-
getFileSystemParent
public File getFileSystemParent()
Description copied from interface:SpoonResource
Gets the parent of this resource on the file system.- Specified by:
getFileSystemParent
in interfaceSpoonResource
-
getName
public String getName()
Description copied from interface:SpoonResource
Gets the name of this resource.- Specified by:
getName
in interfaceSpoonResource
-
isFile
public boolean isFile()
Description copied from interface:SpoonResource
Tells if this resource is a file.- Specified by:
isFile
in interfaceSpoonResource
-
isArchive
public boolean isArchive()
Description copied from interface:SpoonResource
Tells if this resource is an archive.- Specified by:
isArchive
in interfaceSpoonResource
-
getPath
public String getPath()
Description copied from interface:SpoonResource
Gets this resource path.- Specified by:
getPath
in interfaceSpoonResource
-
toFile
public File toFile()
Description copied from interface:SpoonResource
Gets the corresponding file if possible (returns null if this resource does not correspond to any file on the filesystem).- Specified by:
toFile
in interfaceSpoonResource
-
-