Now a day it is very easy to create java projects with the help of using maven archetype artifact.
The next problem is how t ointegrate this maven project in eclipse, so that we do not have to tell eclipse about dependencies again.
I generally use eclipse plugin of maven. Here is the command..
mvn eclipse:eclipse -Dwtpversion=2.0 -DdownloadSources=true -DdownloadJavadocs=true -DoutputDirectory=bin -DeclipseProjectDir=C:\EclipseWorkspace
If you have working eclipse workspace and you copied it to some other machine, if you want to download all maven dependencies once... You can use below command
mvn eclipse:resolve-workspace-dependencies
One can get usage details of each goal by using below command..
mvn eclipse:help -Ddetail=true -Dgoal=eclipse
Here is sample output :
eclipse:eclipse Generates the following eclipse configuration files: - .project and .classpath files - .setting/org.eclipse.jdt.core.prefs with project specific compiler settings - various configuration files for WTP (Web Tools Project), if the parameter wtpversion is set to a valid version (WTP configuration is not generated by default) If this goal is run on a multiproject root, dependencies between modules will be configured as direct project dependencies in Eclipse (unless useProjectReferences is set to false).
Available parameters:
addGroupIdToProjectName (Default: false) If set to true, the groupId of the artifact is appended to the name of the generated Eclipse project. See projectNameTemplate for other options. User property: eclipse.addGroupIdToProjectName
additionalBuildcommands List of eclipse build commands to be added to the default ones. Old style: <additionalBuildcommands>
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand> </additionalBuildcommands> New style: <additionalBuildcommands> <buildCommand> <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name> <triggers>auto,full,incremental,</triggers> <arguments>
<LaunchConfigHandle><project>./externalToolBuilders/MavenBuilder.launch</LaunchConfighandle> </arguments> </buildCommand> </additionalBuildcommands> Note the difference between buildcommand and buildCommand. You can mix and match old and new-style configuration entries.
additionalConfig Allow to configure additional generic configuration files for eclipse that will be written out to disk when running eclipse:eclipse. FOr each file you can specify the name and the text content. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <configuration> <additionalConfig> <file> <name>.checkstyle</name> <content> <![CDATA[<fileset-config file-format-version='1.2.0' simple-config='true'> <fileset name='all' enabled='true' check-config-name='acme corporate style' local='false'> <file-match-pattern match-pattern='.' include-pattern='true'/> </fileset> <filter name='NonSrcDirs' enabled='true'/> </fileset-config>]]> </content> </file> </additionalConfig> </configuration> </plugin> Instead of the content you can also define (from version 2.5) an url to download the file : <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <configuration> <additionalConfig> <file> <name>.checkstyle</name> <url>http://some.place.org/path/to/file</url> </file> </additionalConfig> </configuration> or a location : <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <configuration> <additionalConfig> <file> <name>.checkstyle</name> <location>/checkstyle-config.xml</location> </file> </additionalConfig> </configuration> <dependencies> <!-- The file defined in the location is stored in this dependency --> <dependency> <groupId>eclipsetest</groupId> <artifactId>checkstyle-config</artifactId> <version>1.0</version> </dependency> </dependencies> </plugin>
additionalProjectFacets List of eclipse project facets to be added to the default ones. <additionalProjectFacets> <jst.jsf>1.1<jst.jsf/> </additionalProjectFacets>
additionalProjectnatures List of eclipse project natures to be added to the default ones. <additionalProjectnatures>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature> </additionalProjectnatures>
addVersionToProjectName (Default: false) If set to true, the version number of the artifact is appended to the name of the generated Eclipse project. See projectNameTemplate for other options. User property: eclipse.addVersionToProjectName
ajdtVersion (Default: none) The version of AJDT for which configuration files will be generated. The default value is '1.5', supported versions are 'none' (AJDT support disabled), '1.4', and '1.5'. User property: eclipse.ajdtVersion
buildcommands List of eclipse build commands. By default the org.eclipse.jdt.core.javabuilder builder plus the needed WTP builders are added. If you specify any configuration for this parameter, only those buildcommands specified will be used; the defaults won't be added. Use the additionalBuildCommands parameter for that. Configuration example: Old style: <buildcommands>
<buildcommand>org.eclipse.wst.common.modulecore.ComponentStructuralBuilder</buildcommand> <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
<buildcommand>org.eclipse.wst.common.modulecore.ComponentStructuralBuilderDependencyResolver</buildcommand> </buildcommands> For new style, see additionalBuildCommands.
buildOutputDirectory (Default: ${project.build.outputDirectory}) The default output directory Required: Yes User property: outputDirectory
classpathContainers List of container classpath entries. By default the org.eclipse.jdt.launching.JRE_CONTAINER classpath container is added. Configuration example: <classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v5.5</classpathContainer>
<classpathContainer>org.eclipse.jst.j2ee.internal.web.container/artifact</classpathContainer> </classpathContainers>
classpathContainersLast (Default: false) Put classpath container entries last in eclipse classpath configuration. Note that this behaviour, although useful in situations were you want to override resources found in classpath containers, will made JRE classes loaded after 3rd party jars, so enabling it is not suggested. User property: eclipse.classpathContainersLast
downloadJavadocs Enables/disables the downloading of javadoc attachments. Defaults to false. When this flag is true remote repositories are checked for javadocs: in order to avoid repeated check for unavailable javadoc archives, a status cache is mantained. With versions 2.6+ of the plugin to reset this cache run mvn eclipse:remove-cache, or use the forceRecheck option with versions. With older versions delete the file mvn-eclipse-cache.properties in the target directory. User property: downloadJavadocs
downloadSources Enables/disables the downloading of source attachments. Defaults to false. When this flag is true remote repositories are checked for sources: in order to avoid repeated check for unavailable source archives, a status cache is mantained. With versions 2.6+ of the plugin to reset this cache run mvn eclipse:remove-cache, or use the forceRecheck option with versions. With older versions delete the file mvn-eclipse-cache.properties in the target directory. User property: downloadSources
eclipseDownloadSources Deprecated. use downloadSources
Enables/disables the downloading of source attachments. Defaults to false. DEPRECATED - use downloadSources User property: eclipse.downloadSources
eclipseProjectDir Eclipse workspace directory. User property: eclipse.projectDir
excludes List of artifacts, represented as groupId:artifactId, to exclude from the eclipse classpath, being provided by some eclipse classPathContainer.
forceRecheck Enables/disables the rechecking of the remote repository for downloading source/javadoc attachments. Defaults to false. When this flag is true and the source or javadoc attachment has a status cache to indicate that it is not available, then the remote repository will be rechecked for a source or javadoc attachment and the status cache updated to reflect the new state. User property: forceRecheck
jeeversion The plugin is often capable in predicting the required jee version based on the dependencies of the project. By setting this parameter to one of the jeeversion options the version will be locked. jeeversion EJB version Servlet version JSP version 6.0 3.1 3.0 2.2 5.0 3.0 2.5 2.1 1.4 2.1 2.4 2.0 1.3 2.0 2.3 1.2 1.2 1.1 2.2 1.1 User property: eclipse.jeeversion
limitProjectReferencesToWorkspace (Default: false) Limit the use of project references to the current workspace. No project references will be created to projects in the reactor when they are not available in the workspace. User property: eclipse.limitProjectReferencesToWorkspace
linkedResources A list of links to local files in the system. A configuration like this one in the pom : <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <configuration> <linkedResources> <linkedResource> <name>src/test/resources/oracle-ds.xml</name> <type>1</type> <location>C://jboss/server/default/deploy/oracle-ds.xml</location> </linkedResource> </linkedResources> </configuration> </plugin> will produce in the .project : <linkedResources> <link> <name>src/test/resources/oracle-ds.xml</name> <type>1</type> <location>C://jboss/server/default/deploy/oracle-ds.xml</location> </link> </linkedResources>
manifest (Default: ${basedir}/META-INF/MANIFEST.MF) The relative path of the manifest file User property: eclipse.manifest
packaging The project packaging. User property: project.packaging
preferStandardClasspathContainer (Default: false) If set to true, the standard execution environment matching the compiler settings is set as JRE. If set to false, the JRE matching the configured compiler-plugin executable or JAVA_HOME is selected by name, if it is configured in the workspace. User property: eclipse.preferStandardClasspathContainer
projectNameTemplate Allows configuring the name of the eclipse projects. This property if set wins over addVersionToProjectName and addGroupIdToProjectName You can use [groupId], [artifactId] and [version] variables. eg. [groupId].[artifactId]-[version] User property: eclipse.projectNameTemplate
projectnatures List of eclipse project natures. By default the org.eclipse.jdt.core.javanature nature plus the needed WTP natures are added. Natures added using this property replace the default list. <projectnatures> <projectnature>org.eclipse.jdt.core.javanature</projectnature>
<projectnature>org.eclipse.wst.common.modulecore.ModuleCoreNature</projectnature> </projectnatures>
skip (Default: false) Skip the operation when true. User property: eclipse.skip
sourceExcludes List of exclusions to add to the source directories on the classpath. Adds excluding='' to the classpathentry of the eclipse .classpath file. [MECLIPSE-104]
sourceIncludes List of inclusions to add to the source directories on the classpath. Adds including='' to the classpathentry of the eclipse .classpath file. Java projects will always include '**/*.java'
Ajdt projects will always include '**/*.aj'
[MECLIPSE-104]
testSourcesLast (Default: false) Whether to place test resources after main resources. Note that the default behavior of Maven version 2.0.8 or later is to have test dirs before main dirs in classpath so this is discouraged if you need to reproduce the maven behavior during tests. The default behavior is also changed in eclipse plugin version 2.6 in order to better match the maven one. Switching to 'test source last' can anyway be useful if you need to run your application in eclipse, since there is no concept in eclipse of 'phases' with different set of source dirs and dependencies like we have in maven. User property: eclipse.testSourcesLast
useProjectReferences (Default: true) When set to false, the plugin will not create sub-projects and instead reference those sub-projects using the installed package in the local repository Required: Yes User property: eclipse.useProjectReferences
workspace This eclipse workspace is read and all artifacts detected there will be connected as eclipse projects and will not be linked to the jars in the local repository. Requirement is that it was created with the similar wtp settings as the reactor projects, but the project name template my differ. The pom's in the workspace projects may not contain variables in the artefactId, groupId and version tags. If workspace is not defined, then an attempt to locate it by checking up the directory hierarchy will be made. User property: eclipse.workspace
wtpapplicationxml (Default: false) Must the application files be written for ear projects in a separate directory. User property: eclipse.wtpapplicationxml
wtpContextName JEE context name of the WTP module. ( ex. WEB context name ). You can use 'ROOT' if you want to map the webapp to the root context. User property: wtpContextName
wtpdefaultserver What WTP defined server to use for deployment informations. User property: eclipse.wtpdefaultserver
wtpmanifest (Default: false) Must the manifest files be written for java projects so that that the jee classpath for wtp is correct. User property: eclipse.wtpmanifest
wtpversion (Default: none) The version of WTP for which configuration files will be generated. The default value is 'none' (don't generate WTP configuration), supported versions are 'R7', '1.0', '1.5' and '2.0' User property: wtpversion
No comments:
Post a Comment