MPECLIPSE-127 : add support for wtp 1.5 Dynamically set java and servlet versions in the facet descriptor Add a new property maven.eclipse.enable to avoid to have to define some natures to enable wtp Update documentation Generates project settings to store the compiler source and target levels git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@531133 13f79535-47bb-0310-9956-ffa450edef68
391 lines
20 KiB
XML
391 lines
20 KiB
XML
<?xml version="1.0"?>
|
|
<!--
|
|
/*
|
|
* Copyright 2001-2005 The Apache Software Foundation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
-->
|
|
<project xmlns:j="jelly:core" xmlns:ant="jelly:ant" xmlns:util="jelly:util" xmlns:define="jelly:define"
|
|
xmlns:maven="jelly:maven" xmlns:eclipse="eclipse">
|
|
|
|
<define:taglib uri="eclipse">
|
|
<define:jellybean
|
|
name="download-sources"
|
|
className="org.apache.maven.plugin.eclipse.JavaSourcesDownloader"
|
|
method="downloadSources"/>
|
|
<define:jellybean
|
|
name="download-javadocs"
|
|
className="org.apache.maven.plugin.eclipse.JavadocsDownloader"
|
|
method="downloadSources"/>
|
|
|
|
<define:tag name="write-classpath-entry">
|
|
<maven:param-check value="${groupId}" fail="true" message="'groupId' must be specified" />
|
|
<maven:param-check value="${artifactId}" fail="true" message="'artifactId' must be specified" />
|
|
<maven:param-check value="${version}" fail="false"
|
|
message="'version' should be specified for artifact ${groupId}.${artifactId}" />
|
|
<!-- relativePath is optional, used for jar override -->
|
|
<j:set var="relativePathCheck" value="${relativePath}X" />
|
|
<j:if test='${relativePathCheck == "X"}'>
|
|
<j:set var="relativePath" value="${groupId}/jars/${artifactId}-${version}.jar" />
|
|
</j:if>
|
|
|
|
<!-- download the source from the remote repository if necessary -->
|
|
<j:if test="${maven.eclipse.src.download}">
|
|
<eclipse:download-sources
|
|
project="${pom}"
|
|
groupId="${groupId}"
|
|
artifactId="${artifactId}"
|
|
version="${version}"
|
|
/>
|
|
</j:if>
|
|
|
|
<!--
|
|
should be (m1 repo layout):
|
|
${groupId}/java-sources/${artifactId}-${version}-sources.jar
|
|
-->
|
|
<!-- deprecated: check it first and use it if available, elsewhere set the new path -->
|
|
<j:set var="mappedsrc" value="${groupId}/src/${artifactId}-${version}.${maven.eclipse.src.extension}" />
|
|
<util:file var="srcFile" name="${maven.repo.local}/${mappedsrc}" />
|
|
<j:choose>
|
|
<j:when test="${srcFile.exists()}">
|
|
<j:set var="msg" trim="true">
|
|
<![CDATA[
|
|
deprecated: java sources for ${artifactId} found at MAVEN_REPO/${mappedsrc},
|
|
please use the path MAVEN_REPO/${groupId}/java-sources/${artifactId}-${version}-sources.jar
|
|
]]>
|
|
</j:set>
|
|
<ant:echo>${msg}</ant:echo>
|
|
</j:when>
|
|
<j:otherwise>
|
|
<j:set var="mappedsrc" value="${groupId}/java-sources/${artifactId}-${version}-sources.jar" />
|
|
<util:file var="srcFile" name="${maven.repo.local}/${mappedsrc}" />
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
<!-- If the source file exists, add it to the project, otherwise attempt to
|
|
download the Javadocs if maven.eclipse.javadoc.download is true -->
|
|
<j:choose>
|
|
<j:when test="${srcFile.exists()}">
|
|
<classpathentry kind="var" path="MAVEN_REPO/${relativePath}" sourcepath="MAVEN_REPO/${mappedsrc}"/>
|
|
<j:set var="msg" trim="true">
|
|
Java sources for ${artifactId} at ${srcFile} configured for javadoc and debugging support in Eclipse
|
|
</j:set>
|
|
<ant:echo>${msg}</ant:echo>
|
|
</j:when>
|
|
<j:otherwise>
|
|
<classpathentry kind="var" path="MAVEN_REPO/${relativePath}">
|
|
<j:set var="jdocs" value="${groupId}/javadoc.jars/${artifactId}-${version}-javadoc.jar" />
|
|
<j:if test="${maven.eclipse.javadoc.download}">
|
|
<eclipse:download-javadocs
|
|
project="${pom}"
|
|
groupId="${groupId}"
|
|
artifactId="${artifactId}"
|
|
version="${version}"/>
|
|
</j:if>
|
|
<util:file var="jdocsFile" name="${maven.repo.local}/${jdocs}" />
|
|
<j:if test="${jdocsFile.exists()}">
|
|
<j:set var="msg" trim="true">
|
|
Javadoc for ${artifactId} at ${jdocsFile} configured in Eclipse
|
|
</j:set>
|
|
<ant:echo>${msg}</ant:echo>
|
|
<attributes>
|
|
<attribute value="jar:file:/${maven.repo.local}/${jdocs}!/" name="javadoc_location"/>
|
|
</attributes>
|
|
</j:if>
|
|
</classpathentry>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
</define:tag>
|
|
</define:taglib>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Generate Eclipse .project and .classpath files (and wtp settings)-->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse:eclipse" description="Generate Eclipse project files" prereqs="eclipse:generate-project">
|
|
<j:if test="${sourcesPresent or !pom.build.resources.isEmpty()}">
|
|
<attainGoal name="eclipse:generate-classpath" />
|
|
</j:if>
|
|
<j:if test="${maven.eclipse.wtp.enable==true}">
|
|
<attainGoal name="eclipse:generate-wtpmodules" />
|
|
</j:if>
|
|
<ant:echo>Now refresh your project in Eclipse (right click on the project and select "Refresh")</ant:echo>
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Alias for eclipse:eclipse -->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse" description="Generate Eclipse project files" prereqs="eclipse:eclipse"></goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Generate Eclipse .project file -->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse:generate-project" description="Generate Eclipse .project file">
|
|
<ant:echo>Creating ${basedir}/.project ...</ant:echo>
|
|
<j:file name="${basedir}/.project" prettyPrint="true" xmlns="dummy">
|
|
<j:import file="${plugin.resources}/templates/project.jelly" inherit="true" />
|
|
</j:file>
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Generate Eclipse .classpath file -->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse:generate-classpath" description="Generate Eclipse .classpath file">
|
|
<ant:echo>Creating ${basedir}/.classpath ...</ant:echo>
|
|
<j:file name="${basedir}/.classpath" prettyPrint="true" outputMode="xml" xmlns="dummy">
|
|
<j:import file="${plugin.resources}/templates/classpath.jelly" inherit="true" />
|
|
</j:file>
|
|
<ant:mkdir dir="${basedir}/.settings"/>
|
|
<ant:echo>Creating ${basedir}/.settings/org.eclipse.jdt.core.prefs ...</ant:echo>
|
|
<j:file name="${basedir}/.settings/org.eclipse.jdt.core.prefs" omitXmlDeclaration="true" outputMode="txt" xmlns="dummy">
|
|
<j:import file="${plugin.resources}/templates/org.eclipse.jdt.core.prefs.jelly" inherit="true" />
|
|
</j:file>
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Generate Eclipse .wtpmodules file -->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse:generate-wtpmodules" description="Generate Eclipse .wtpmodules file">
|
|
<j:choose>
|
|
<j:when test="${maven.eclipse.wtp.version==0.7}">
|
|
<ant:echo>Creating ${basedir}/.wtpmodules ...</ant:echo>
|
|
<j:file name="${basedir}/.wtpmodules" prettyPrint="true" outputMode="xml" xmlns="dummy">
|
|
<j:import file="${plugin.resources}/templates/wtp/0.7/wtpmodules.jelly" inherit="true" />
|
|
</j:file>
|
|
</j:when>
|
|
<j:when test="${maven.eclipse.wtp.version==1.5}">
|
|
<ant:mkdir dir="${basedir}/.settings"/>
|
|
<ant:echo>Creating ${basedir}/.settings/org.eclipse.wst.common.component ...</ant:echo>
|
|
<j:file name="${basedir}/.settings/org.eclipse.wst.common.component" prettyPrint="true" outputMode="xml" xmlns="dummy">
|
|
<j:import file="${plugin.resources}/templates/wtp/1.5/org.eclipse.wst.common.component.jelly" inherit="true" />
|
|
</j:file>
|
|
<ant:echo>Creating ${basedir}/.settings/org.eclipse.wst.common.project.facet.core.xml ...</ant:echo>
|
|
<j:file name="${basedir}/.settings/org.eclipse.wst.common.project.facet.core.xml" prettyPrint="true" outputMode="xml" xmlns="dummy">
|
|
<j:import file="${plugin.resources}/templates/wtp/1.5/org.eclipse.wst.common.project.facet.core.xml.jelly" inherit="true" />
|
|
</j:file>
|
|
</j:when>
|
|
<j:otherwise>
|
|
<ant:fail>maven.eclipse.wtp.version=${maven.eclipse.wtp.version} not supported. Please check the plugin documentation to have the list of supported values.</ant:fail>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Generate Eclipse mappings for Maven goals -->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse:external-tools" description="Generate an Eclipse external tool for each goal">
|
|
<ant:mkdir dir="${maven.build.dir}/eclipse/" />
|
|
<j:set var="toolFile" value="${maven.build.dir}/eclipse/externaltools.xml" />
|
|
<ant:echo>Creating ${toolFile}</ant:echo>
|
|
<j:set var="os" value="${os.name}" />
|
|
<j:set var="windows" value="${os.toLowerCase().indexOf('windows') != '-1'}" />
|
|
<ant:echo>Adapting the generated file for a ${os} box.</ant:echo>
|
|
<!-- Strangely, j:file inserts a space between ${maven.home} and /bin/maven ... -->
|
|
<j:set var="tool.loc" value="${maven.home}${file.separator}bin${file.separator}maven" />
|
|
<j:if test="${windows}">
|
|
<j:set var="tool.loc" value="${tool.loc}.bat" />
|
|
</j:if>
|
|
<j:file name="${toolFile}" prettyPrint="true" xmlns="dummy">
|
|
<externaltools>
|
|
<j:set var="project" value="${org.apache.commons.jelly.werkz.Project}" />
|
|
<j:set var="session" value="${maven.session}" />
|
|
<j:forEach var="goal" items="${session.allGoalNames}">
|
|
<j:set var="maven.eclipse.generate" value="false" />
|
|
<j:set var="allGoals" value="${maven.eclipse.goals}" />
|
|
<j:choose>
|
|
<j:when test="${allGoals == 'all'}">
|
|
<j:set var="maven.eclipse.generate" value="true" />
|
|
</j:when>
|
|
<j:otherwise> <!-- = plugins -->
|
|
<!-- Only main goals for plugins -->
|
|
<j:if test="${goal.indexOf(':') == '-1'}">
|
|
<j:set var="maven.eclipse.generate" value="true" />
|
|
</j:if>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
<j:if test="${maven.eclipse.generate}">
|
|
<tool>
|
|
<entry key="!{tool_refresh}">$${project}</entry>
|
|
<entry key="!{tool_show_log}">true</entry>
|
|
<entry key="!{tool_loc}">${tool.loc}</entry>
|
|
<entry key="!{tool_args}">-e -p $${resource_loc} ${goal}</entry>
|
|
<entry key="!{tool_block}">false</entry>
|
|
<entry key="!{tool_type}">org.eclipse.ui.externaltools.type.program</entry>
|
|
<entry key="!{tool_dir}">$${container_loc}</entry>
|
|
<entry key="!{tool_build_types}"></entry>
|
|
<entry key="!{tool_name}">Maven ${goal}</entry>
|
|
</tool>
|
|
</j:if>
|
|
</j:forEach>
|
|
</externaltools>
|
|
</j:file>
|
|
<j:set var="ws" value="${maven.eclipse.workspace}X" />
|
|
<j:if test='${ws != "X"}'>
|
|
<j:set var="toDir" value="${maven.eclipse.workspace}/.metadata/.plugins/org.eclipse.ui.externaltools/" />
|
|
<ant:copy file="${toolFile}" todir="${toDir}" />
|
|
</j:if>
|
|
<j:if test='${ws == "X"}'>
|
|
<j:set var="msg" trim="true">
|
|
<![CDATA[
|
|
Please set maven.eclipse.workspace to the location of your eclipse workspace.
|
|
Alternatively, copy ${maven.build.dir}/eclipse/externaltools.xml to [maven.eclipse.workspace]/.metadata/.plugins/org.eclipse.ui.externaltools/externaltools.xml
|
|
]]>
|
|
</j:set>
|
|
<ant:echo>${msg}</ant:echo>
|
|
</j:if>
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Generate Eclipse mappings for Maven goals -->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse:external-tools-21" description="Generate an Eclipse 2.1 external tool for each goal">
|
|
<ant:mkdir dir="${maven.build.dir}/eclipse/" />
|
|
<ant:echo>Creating external tools</ant:echo>
|
|
<j:set var="os" value="${os.name}" />
|
|
<j:set var="windows" value="${os.toLowerCase().indexOf('windows') != '-1'}" />
|
|
<ant:echo>Adapting the generated file for a ${os} box.</ant:echo>
|
|
<!-- Strangely, j:file inserts a space between ${maven.home} and /bin/maven ... -->
|
|
<j:set var="tool.loc" value="${maven.home}${file.separator}bin${file.separator}maven" />
|
|
<j:if test="${windows}">
|
|
<j:set var="tool.loc" value="${tool.loc}.bat" />
|
|
</j:if>
|
|
<j:set var="project" value="${org.apache.commons.jelly.werkz.Project}" />
|
|
<j:set var="allGoals" value="${maven.eclipse.goals}" />
|
|
<j:set var="session" value="${maven.session}" />
|
|
<j:forEach var="goal" items="${session.allGoalNames}">
|
|
<util:replace var="goalName" oldChar=":" newChar="-" value="${goal}" />
|
|
<j:set var="fileName" value="${maven.build.dir}/eclipse/maven ${goalName}.launch" />
|
|
<j:set var="maven.eclipse.generate" value="false" />
|
|
<j:choose>
|
|
<j:when test="${allGoals == 'all'}">
|
|
<j:set var="maven.eclipse.generate" value="true" />
|
|
</j:when>
|
|
<j:otherwise>
|
|
<j:if test="${goal.indexOf(':') == '-1'}">
|
|
<j:set var="maven.eclipse.generate" value="true" />
|
|
</j:if>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
<j:if test="${maven.eclipse.generate}">
|
|
<ant:echo>Generating ${fileName}</ant:echo>
|
|
<j:file name="${fileName}" prettyPrint="true" xmlns="dummy">
|
|
<j:import file="${plugin.resources}/templates/launch.jelly" inherit="true" />
|
|
</j:file>
|
|
</j:if>
|
|
</j:forEach>
|
|
<j:set var="ws" value="${maven.eclipse.workspace}X" />
|
|
<j:if test='${ws != "X"}'>
|
|
<j:set var="toDir" value="${maven.eclipse.workspace}/.metadata/.plugins/org.eclipse.debug.core/.launches/" />
|
|
<ant:copy todir="${toDir}">
|
|
<ant:fileset dir="${maven.build.dir}/eclipse/" includes="*.launch" />
|
|
</ant:copy>
|
|
</j:if>
|
|
<j:if test='${ws == "X"}'>
|
|
<j:set var="msg" trim="true">
|
|
<![CDATA[
|
|
Please set maven.eclipse.workspace to the location of your eclipse workspace.
|
|
Alternatively, copy ${maven.build.dir}/eclipse/*.launch to [maven.eclipse.workspace]/.metadata/.plugins/org.eclipse.debug.core/.launches/
|
|
]]>
|
|
</j:set>
|
|
<ant:echo>${msg}</ant:echo>
|
|
</j:if>
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Add MAVEN_REPO to classpath variables -->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse:add-maven-repo" description="Ensure that the classpath variable MAVEN_REPO is available">
|
|
<j:set var="ws" value="${maven.eclipse.workspace}X" />
|
|
<j:choose>
|
|
<j:when test='${ws != "X"}'>
|
|
<j:set var="variableDir"
|
|
value="${maven.eclipse.workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings/" />
|
|
<j:set var="variableFile" value="${variableDir}/org.eclipse.jdt.core.prefs" />
|
|
<!-- create the Eclipse property file if it is missing -->
|
|
<ant:mkdir dir="${variableDir}" />
|
|
<ant:touch file="${variableFile}" />
|
|
<ant:propertyfile file="${variableFile}">
|
|
<ant:entry key="org.eclipse.jdt.core.classpathVariable.MAVEN_REPO" default="${maven.repo.local}" />
|
|
</ant:propertyfile>
|
|
</j:when>
|
|
<j:otherwise>The property $${maven.eclipse.workspace} was not set. MAVEN_REPO may not be set.</j:otherwise>
|
|
</j:choose>
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Clean up eclipse generated files -->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse:clean" description="Clean eclipse generated files">
|
|
<ant:delete file="${basedir}/.project" />
|
|
<ant:delete file="${basedir}/.classpath" />
|
|
<!-- WTP 0.7 files -->
|
|
<ant:delete file="${basedir}/.wtpmodules" />
|
|
<!-- WTP 1.5 files -->
|
|
<ant:delete file="${basedir}/.settings/org.eclipse.wst.common.component" />
|
|
<ant:delete file="${basedir}/.settings/org.eclipse.wst.common.project.facet.core.xml" />
|
|
<ant:echo>Cleaned up eclipse generated files</ant:echo>
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Init multiproject -->
|
|
<!--==================================================================-->
|
|
|
|
<goal name="eclipse:multiinit" description="Initialize multiproject settings">
|
|
<j:if test="${!init_already_executed}">
|
|
<!-- Default reactor properties from the Multiproject plug-in -->
|
|
<!-- Make sure the multiproject plugin is loaded -->
|
|
<maven:set plugin="maven-multiproject-plugin" property="foo" value="bar"/>
|
|
<maven:get var="mBasedir" property="maven.multiproject.basedir" plugin="maven-multiproject-plugin"/>
|
|
<maven:property var="dBasedir" name="maven.eclipse.multiproject.basedir" defaultValue="${mBasedir}"/>
|
|
<maven:get var="mIncludes" property="maven.multiproject.includes" plugin="maven-multiproject-plugin"/>
|
|
<maven:property var="dIncludes" name="maven.eclipse.multiproject.includes" defaultValue="${mIncludes}"/>
|
|
<maven:get var="mExcludes" property="maven.multiproject.excludes" plugin="maven-multiproject-plugin"/>
|
|
<maven:property var="dExcludes" name="maven.eclipse.multiproject.excludes" defaultValue="${mExcludes}"/>
|
|
<maven:get var="mIgnoreFailures" property="maven.multiproject.ignoreFailures" plugin="maven-multiproject-plugin"/>
|
|
<maven:property var="dIgnoreFailures" name="maven.eclipse.multiproject.ignoreFailures" defaultValue="${mIgnoreFailures}"/>
|
|
<j:set var="init_already_executed" value="true"/>
|
|
</j:if>
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Call eclipse:eclipse in multiproject -->
|
|
<!--==================================================================-->
|
|
|
|
<goal name="eclipse:multiproject" description="Launch the eclipse goal in a multiproject context" prereqs="eclipse:multiinit">
|
|
<maven:reactor
|
|
basedir="${mBasedir}"
|
|
banner="Creating eclipse settings for : "
|
|
includes="${mIncludes}"
|
|
excludes="${mExcludes}"
|
|
postProcessing="true"
|
|
goals="eclipse"
|
|
ignoreFailures="${mIgnoreFailures}"/>
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Call eclipse:clean in multiproject -->
|
|
<!--==================================================================-->
|
|
|
|
<goal name="eclipse:multiclean" description="Launch the eclipse:clean goal in a multiproject context" prereqs="eclipse:multiinit">
|
|
<maven:reactor
|
|
basedir="${mBasedir}"
|
|
banner="Deleting eclipse settings for :"
|
|
includes="${mIncludes}"
|
|
excludes="${mExcludes}"
|
|
postProcessing="true"
|
|
goals="eclipse:clean"
|
|
ignoreFailures="${mIgnoreFailures}"/>
|
|
</goal>
|
|
|
|
</project>
|