Class EclipseToMavenMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo,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/oxygen
Note: 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
FieldsModifier and TypeFieldDescriptionprotected org.codehaus.plexus.components.interactivity.InputHandlerInput handler, needed for command line handling.protected org.apache.maven.artifact.installer.ArtifactInstallerArtifactInstaller component.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcontextualize(org.codehaus.plexus.context.Context context) protected StringcreateArtifactId(String bundleName) Get the artifact id as the tokens after last dot e.g.protected StringcreateGroupId(String bundleName) Get the group id as the tokens until last dot e.g.voidexecute()protected StringfixBuildNumberSeparator(String versionRange) Fix the separator for the 4th token in a versions.protected StringgetKey(org.apache.maven.model.Model model) protected StringgetSourceKey(org.apache.maven.model.Model model) protected StringosgiVersionToMavenVersion(String version) protected StringosgiVersionToMavenVersion(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 voidprocessFile(File file, Map<String, EclipseOsgiPlugin> plugins, Map<String, org.apache.maven.model.Model> models) protected voidprocessPlugin(EclipseOsgiPlugin plugin, org.apache.maven.model.Model model, Map<String, EclipseOsgiPlugin> plugins, Map<String, org.apache.maven.model.Model> models) protected voidresolveVersions(Map<String, org.apache.maven.model.Model> models) Resolve dependency versions in the models, that did not declare a version at all.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
installer
@Component protected org.apache.maven.artifact.installer.ArtifactInstaller installerArtifactInstaller component. -
inputHandler
@Component protected org.codehaus.plexus.components.interactivity.InputHandler inputHandlerInput handler, needed for command line handling.
-
-
Constructor Details
-
EclipseToMavenMojo
public EclipseToMavenMojo()
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Specified by:
executein interfaceorg.apache.maven.plugin.Mojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException- See Also:
-
processFile
protected void processFile(File file, Map<String, EclipseOsgiPlugin> plugins, Map<String, throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionorg.apache.maven.model.Model> models) - Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
processPlugin
protected void processPlugin(EclipseOsgiPlugin plugin, org.apache.maven.model.Model model, Map<String, EclipseOsgiPlugin> plugins, Map<String, throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionorg.apache.maven.model.Model> models) - Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
getKey
-
getSourceKey
-
resolveVersions
protected void resolveVersions(Map<String, org.apache.maven.model.Model> models) throws org.apache.maven.plugin.MojoFailureExceptionResolve dependency versions in the models, that did not declare a version at all.- Parameters:
models-- Throws:
org.apache.maven.plugin.MojoFailureException
-
osgiVersionToMavenVersion
-
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:
contextualizein interfaceorg.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable- Throws:
org.codehaus.plexus.context.ContextException
-
createGroupId
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
Get the artifact id as the tokens after last dot e.g.org.eclipse.jdt->jdt- Parameters:
bundleName- bundle name- Returns:
- artifact id
-
parseDependencies
Parses the "Require-Bundle" and convert it to a list of dependencies.- Parameters:
requireBundle- "Require-Bundle" entry- Returns:
- an array of
Dependency
-
fixBuildNumberSeparator
Fix the separator for the 4th token in a versions. In maven this must be "-", in OSGI it's "."- Parameters:
versionRange- input range- Returns:
- modified version range
-