public class IdeUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
JAVA_1_1 |
static String |
JAVA_1_2 |
static String |
JAVA_1_3 |
static String |
JAVA_1_4 |
static String |
JAVA_5_0 |
static String |
JAVA_6_0 |
static String |
NOT_AVAILABLE_MARKER_FILE_SUFFIX
The suffix used to mark a file as not available.
|
static String |
PROJECT_NAME_DEFAULT_TEMPLATE |
static String |
PROJECT_NAME_WITH_GROUP_AND_VERSION_TEMPLATE |
static String |
PROJECT_NAME_WITH_GROUP_TEMPLATE |
static String |
PROJECT_NAME_WITH_VERSION_TEMPLATE |
Modifier and Type | Method and Description |
---|---|
static String |
calculateProjectNameTemplate(String projectNameTemplate,
boolean addVersionToProjectName,
boolean addGroupIdToProjectName,
Log log)
Calculate the project name template from the specified value
projectNameTemplate ,
addVersionToProjectName and addGroupIdToProjectName
Note: if projectNameTemplate is not null then that value will be used regardless of the values for
addVersionToProjectName or addGroupIdToProjectName and a warning will be issued. |
static Artifact |
createArtifactWithClassifier(String groupId,
String artifactId,
String version,
String depClassifier,
String inClassifier,
ArtifactFactory artifactFactory)
Wrap
ArtifactFactory.createArtifactWithClassifier(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) so that the type and classifier are set correctly for
"sources" and "javadoc". |
static void |
delete(File f,
Log log)
Delete a file, handling log messages and exceptions
|
static String |
fixSeparator(String filename)
Convert the provided filename from a Windows separator \\ to a unix/java separator /
|
static String |
fixWindowsDriveURI(String input)
NOTE: This is to account for the unfortunate fact that "file:" URIs differ between Windows and Unix.
|
static ArtifactVersion |
getArtifactVersion(String[] artifactIds,
List dependencies) |
static String |
getArtifactVersion(String[] artifactIds,
List dependencies,
int len)
Extracts the version of the first matching artifact in the given list.
|
static String |
getCanonicalPath(File file) |
static String |
getCompilerPluginSetting(MavenProject project,
String optionName)
Returns a compiler plugin settings, considering also settings altered in plugin executions .
|
static String |
getCompilerSourceEncoding(MavenProject project)
Returns the source encoding configured for the compiler plugin.
|
static String |
getCompilerSourceVersion(MavenProject project)
Returns the source version configured for the compiler plugin.
|
static String |
getCompilerTargetVersion(MavenProject project)
Returns the target version configured for the compiler plugin.
|
static File |
getNotAvailableMarkerFile(ArtifactRepository localRepository,
Artifact artifact) |
static Xpp3Dom |
getPluginConfigurationDom(MavenProject project,
String pluginId)
Search for the configuration Xpp3 dom of an other plugin.
|
static Xpp3Dom[] |
getPluginConfigurationDom(MavenProject project,
String artifactId,
String[] subConfiguration)
Search for the configuration Xpp3 dom of an other plugin.
|
static String |
getPluginSetting(MavenProject project,
String pluginId,
String optionName,
String defaultValue)
Search for a configuration setting of an other plugin for a configuration setting.
|
static String |
getProjectName(MavenProject project,
boolean addVersionToProjectName) |
static String |
getProjectName(String template,
Artifact artifact)
Use the project name template to create an eclipse project.
|
protected static String |
getProjectName(String template,
IdeDependency dep)
Use
IdeDependency.getEclipseProjectName() instead. |
static String |
getProjectName(String template,
MavenProject project) |
static Artifact |
resolveArtifact(ArtifactResolver artifactResolver,
Artifact artifact,
List remoteRepos,
ArtifactRepository localRepository,
Log log)
Wrapper around
ArtifactResolver.resolve(Artifact, List, ArtifactRepository) |
static String |
resolveJavaVersion(MavenProject project) |
static String |
toRelativeAndFixSeparator(File basedir,
File fileToAdd,
boolean replaceSlashesWithDashes) |
public static final String JAVA_1_1
public static final String JAVA_1_2
public static final String JAVA_1_3
public static final String JAVA_1_4
public static final String JAVA_5_0
public static final String JAVA_6_0
public static final String PROJECT_NAME_DEFAULT_TEMPLATE
public static final String PROJECT_NAME_WITH_VERSION_TEMPLATE
public static final String PROJECT_NAME_WITH_GROUP_TEMPLATE
public static final String PROJECT_NAME_WITH_GROUP_AND_VERSION_TEMPLATE
public static final String NOT_AVAILABLE_MARKER_FILE_SUFFIX
public static void delete(File f, Log log) throws MojoExecutionException
f
- File to be deletedMojoExecutionException
- only if a file exists and can't be deletedpublic static String getCanonicalPath(File file) throws MojoExecutionException
MojoExecutionException
public static String getCompilerPluginSetting(MavenProject project, String optionName)
project
- maven projectpublic static String getCompilerSourceVersion(MavenProject project)
project
- maven projectpublic static String getCompilerSourceEncoding(MavenProject project)
project
- maven projectpublic static String getCompilerTargetVersion(MavenProject project)
project
- maven projectpublic static String getArtifactVersion(String[] artifactIds, List dependencies, int len)
The len
parameter indicated what to to return:
major
versionmajor dot minor
versionmajor dot minor dot incremental
version
artifactIds
- artifact names to compare against for extracting versionartifacts
- Set of artifacts for our projectlen
- expected length of the version sub-stringpublic static ArtifactVersion getArtifactVersion(String[] artifactIds, List dependencies)
artifactIds
- an array of artifactIds, should not be null
dependencies
- a list of Dependency
-objects, should not be null
null
public static String getPluginSetting(MavenProject project, String pluginId, String optionName, String defaultValue)
project
- the current maven project to get the configuration from.pluginId
- the group id and artifact id of the plugin to search foroptionName
- the option to get from the configurationdefaultValue
- the default value if the configuration was not foundpublic static Xpp3Dom getPluginConfigurationDom(MavenProject project, String pluginId)
project
- the current maven project to get the configuration from.pluginId
- the group id and artifact id of the plugin to search forpublic static Xpp3Dom[] getPluginConfigurationDom(MavenProject project, String artifactId, String[] subConfiguration)
project
- the current maven project to get the configuration from.artifactId
- the artifact id of the plugin to search forpublic static String calculateProjectNameTemplate(String projectNameTemplate, boolean addVersionToProjectName, boolean addGroupIdToProjectName, Log log)
projectNameTemplate
,
addVersionToProjectName
and addGroupIdToProjectName
Note: if projectNameTemplate is not null then that value will be used regardless of the values for addVersionToProjectName or addGroupIdToProjectName and a warning will be issued.
projectNameTemplate
- the current projectNameTemplate, if availableaddVersionToProjectName
- whether to include Version in the project nameaddGroupIdToProjectName
- whether to include GroupId in the project name.protected static String getProjectName(String template, IdeDependency dep)
IdeDependency.getEclipseProjectName()
instead.public static String getProjectName(String template, Artifact artifact)
template
- Template for the project nameartifact
- the artifact to create the project name forpublic static String getProjectName(String template, MavenProject project)
public static String getProjectName(MavenProject project, boolean addVersionToProjectName)
public static File getNotAvailableMarkerFile(ArtifactRepository localRepository, Artifact artifact)
artifact
- the artifactpublic static Artifact resolveArtifact(ArtifactResolver artifactResolver, Artifact artifact, List remoteRepos, ArtifactRepository localRepository, Log log)
ArtifactResolver.resolve(Artifact, List, ArtifactRepository)
artifactResolver
- see ArtifactResolver.resolve(Artifact, List, ArtifactRepository)
artifact
- see ArtifactResolver.resolve(Artifact, List, ArtifactRepository)
remoteRepos
- see ArtifactResolver.resolve(Artifact, List, ArtifactRepository)
localRepository
- see ArtifactResolver.resolve(Artifact, List, ArtifactRepository)
log
- Loggerpublic static Artifact createArtifactWithClassifier(String groupId, String artifactId, String version, String depClassifier, String inClassifier, ArtifactFactory artifactFactory)
ArtifactFactory.createArtifactWithClassifier(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
so that the type and classifier are set correctly for
"sources" and "javadoc".groupId
- see ArtifactFactory.createArtifactWithClassifier(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
artifactId
- see ArtifactFactory.createArtifactWithClassifier(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
version
- see ArtifactFactory.createArtifactWithClassifier(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
depClassifier
- see ArtifactFactory.createArtifactWithClassifier(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
inClassifier
- either "sources" of "javadoc"artifactFactory
- see ArtifactFactory.createArtifactWithClassifier(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
ArtifactFactory.createArtifactWithClassifier(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
ArtifactFactory.createArtifactWithClassifier(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public static String resolveJavaVersion(MavenProject project)
public static String toRelativeAndFixSeparator(File basedir, File fileToAdd, boolean replaceSlashesWithDashes) throws MojoExecutionException
MojoExecutionException
public static String fixSeparator(String filename)
filename
- file name to fix separatorpublic static String fixWindowsDriveURI(String input)
input
- string input that may contain a windows URICopyright © 2002–2015 The Apache Software Foundation. All rights reserved.