Class EclipseToMavenMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugin.eclipse.EclipseToMavenMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
,org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
@Mojo(name="to-maven", requiresProject=false) public class EclipseToMavenMojo extends org.apache.maven.plugin.AbstractMojo implements org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
Add Eclipse artifacts from an Eclipse installation or a local P2 repo to the local Maven repo.
This mojo automatically analyzes the local P2 repo, copies jars from the plugins directory to the local maven repo, and generates appropriate poms.
Typical usage for a local Eclipse installation:
mvn eclipse:to-maven -DdeployTo=maven.org::default::scpexe://repo1.maven.org/home/maven/repository-staging/to-ibiblio/eclipse-staging -DeclipseDir=/opt/eclipse
Or to download and convert a P2 repository:
/opt/eclipse/eclipse -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication -writeMode clean -verbose -raw -ignoreErrors -source http://download.eclipse.org/releases/oxygen -destination file:/tmp/p2-oxygen
mvn eclipse:to-maven -DbundleNameAsArtifactId=true -DgroupIdTokens=3 -DattachSourcePlugins -DresolveVersionRanges -DdeployTo=oxygen::default::file:/tmp/repo-2018-12 -DeclipseDir=/tmp/oxygenNote: The size of such an update site (P2 repository) is 3 to 4 GB and the download can take several hours.
- Version:
- $Id$
- Author:
- Fabrizio Giustina, Carlos Sanchez
-
-
Field Summary
Fields Modifier and Type Field Description protected org.codehaus.plexus.components.interactivity.InputHandler
inputHandler
Input handler, needed for command line handling.protected org.apache.maven.artifact.installer.ArtifactInstaller
installer
ArtifactInstaller component.
-
Constructor Summary
Constructors Constructor Description EclipseToMavenMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
contextualize(org.codehaus.plexus.context.Context context)
protected String
createArtifactId(String bundleName)
Get the artifact id as the tokens after last dot e.g.protected String
createGroupId(String bundleName)
Get the group id as the tokens until last dot e.g.void
execute()
protected String
fixBuildNumberSeparator(String versionRange)
Fix the separator for the 4th token in a versions.protected String
getKey(org.apache.maven.model.Model model)
protected String
getSourceKey(org.apache.maven.model.Model model)
protected String
osgiVersionToMavenVersion(String version)
protected String
osgiVersionToMavenVersion(String version, String forcedQualifier, boolean stripQualifier)
The 4th (build) token MUST be separated with "-" and not with "." in maven.protected org.apache.maven.model.Dependency[]
parseDependencies(String requireBundle)
Parses the "Require-Bundle" and convert it to a list of dependencies.protected void
processFile(File file, Map<String,EclipseOsgiPlugin> plugins, Map<String,org.apache.maven.model.Model> models)
protected void
processPlugin(EclipseOsgiPlugin plugin, org.apache.maven.model.Model model, Map<String,EclipseOsgiPlugin> plugins, Map<String,org.apache.maven.model.Model> models)
protected void
resolveVersions(Map<String,org.apache.maven.model.Model> models)
Resolve dependency versions in the models, that did not declare a version at all.
-
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Specified by:
execute
in interfaceorg.apache.maven.plugin.Mojo
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
- See Also:
Mojo.execute()
-
processFile
protected void processFile(File file, Map<String,EclipseOsgiPlugin> plugins, Map<String,org.apache.maven.model.Model> models) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
processPlugin
protected void processPlugin(EclipseOsgiPlugin plugin, org.apache.maven.model.Model model, Map<String,EclipseOsgiPlugin> plugins, Map<String,org.apache.maven.model.Model> models) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
getKey
protected String getKey(org.apache.maven.model.Model model)
-
getSourceKey
protected String getSourceKey(org.apache.maven.model.Model model)
-
resolveVersions
protected void resolveVersions(Map<String,org.apache.maven.model.Model> models) throws org.apache.maven.plugin.MojoFailureException
Resolve dependency versions in the models, that did not declare a version at all.- Parameters:
models
-- Throws:
org.apache.maven.plugin.MojoFailureException
-
osgiVersionToMavenVersion
protected String osgiVersionToMavenVersion(String version, String forcedQualifier, boolean stripQualifier)
The 4th (build) token MUST be separated with "-" and not with "." in maven. A version with 4 dots is not parsed, and the whole string is considered a qualifier. See tests in DefaultArtifactVersion for reference.- Parameters:
version
- initial versionforcedQualifier
- build numberstripQualifier
- always remove 4th token in version- Returns:
- converted version
-
contextualize
public void contextualize(org.codehaus.plexus.context.Context context) throws org.codehaus.plexus.context.ContextException
- Specified by:
contextualize
in interfaceorg.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
- Throws:
org.codehaus.plexus.context.ContextException
-
createGroupId
protected String createGroupId(String bundleName)
Get the group id as the tokens until last dot e.g.org.eclipse.jdt
->org.eclipse
- Parameters:
bundleName
- bundle name- Returns:
- group id
-
createArtifactId
protected String createArtifactId(String bundleName)
Get the artifact id as the tokens after last dot e.g.org.eclipse.jdt
->jdt
- Parameters:
bundleName
- bundle name- Returns:
- artifact id
-
parseDependencies
protected org.apache.maven.model.Dependency[] parseDependencies(String requireBundle)
Parses the "Require-Bundle" and convert it to a list of dependencies.- Parameters:
requireBundle
- "Require-Bundle" entry- Returns:
- an array of
Dependency
-
-