You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2013/08/27 16:16:57 UTC
svn commit: r1517827 [14/24] - in /maven/plugins/trunk:
maven-acr-plugin/src/main/java/org/apache/maven/plugin/acr/
maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/
maven-ant-plugin/src/test/java/org/apache/maven/plugin/ant/stubs/
maven-antr...
Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpApplicationXMLWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpApplicationXMLWriter.java?rev=1517827&r1=1517826&r2=1517827&view=diff
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpApplicationXMLWriter.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpApplicationXMLWriter.java Tue Aug 27 14:16:42 2013
@@ -29,7 +29,7 @@ import org.codehaus.plexus.util.xml.Xpp3
* This writer creates the application.xml and the .modulemaps files for RAD6 the the META-INF directory in the project
* root. this is where RAD6 requires the files to be. These will be independent of the real application.xml witch will
* be generated the stad. maven way.
- *
+ *
* @author <a href="mailto:nir@cfc.at">Richard van Nieuwenhoven</a>
*/
public class EclipseWtpApplicationXMLWriter
@@ -102,9 +102,9 @@ public class EclipseWtpApplicationXMLWri
/**
* write the application.xml and the .modulemaps file to the META-INF directory.
- *
- * @see AbstractWtpResourceWriter#write(EclipseSourceDir[], ArtifactRepository, File)
+ *
* @throws MojoExecutionException when writing the config files was not possible
+ * @see AbstractWtpResourceWriter#write(EclipseSourceDir[], ArtifactRepository, File)
*/
public void write()
throws MojoExecutionException
@@ -112,10 +112,10 @@ public class EclipseWtpApplicationXMLWri
String packaging = this.config.getProject().getPackaging();
if ( Constants.PROJECT_PACKAGING_EAR.equalsIgnoreCase( packaging ) )
{
- File applicationXmlFile =
- new File( this.config.getEclipseProjectDirectory(), "target" + File.separator + "eclipseEar"
- + File.separator + "META-INF" + File.separator
- + EclipseWtpApplicationXMLWriter.APPLICATION_XML_FILENAME );
+ File applicationXmlFile = new File( this.config.getEclipseProjectDirectory(),
+ "target" + File.separator + "eclipseEar" + File.separator + "META-INF"
+ + File.separator
+ + EclipseWtpApplicationXMLWriter.APPLICATION_XML_FILENAME );
// create the directory structiure for eclipse deployment
applicationXmlFile.getParentFile().mkdirs();
// copy all deployment files to the eclipse deployment
@@ -132,9 +132,10 @@ public class EclipseWtpApplicationXMLWri
this.applicationXmlDomChildren =
applicationXmlDom.getChildren( EclipseWtpApplicationXMLWriter.APPLICATION_XML_MODULE );
- File modulemapsXmlFile =
- new File( this.config.getEclipseProjectDirectory(), "target" + File.separator + "eclipseEar"
- + File.separator + "META-INF" + File.separator + EclipseWtpApplicationXMLWriter.MODULEMAPS_FILENAME );
+ File modulemapsXmlFile = new File( this.config.getEclipseProjectDirectory(),
+ "target" + File.separator + "eclipseEar" + File.separator + "META-INF"
+ + File.separator
+ + EclipseWtpApplicationXMLWriter.MODULEMAPS_FILENAME );
Xpp3Dom modulemapsXmlDom = readXMLFile( modulemapsXmlFile );
if ( modulemapsXmlDom == null )
{
@@ -144,11 +145,12 @@ public class EclipseWtpApplicationXMLWri
this.webModulesFromPoms =
IdeUtils.getPluginConfigurationDom( config.getProject(), JeeUtils.ARTIFACT_MAVEN_EAR_PLUGIN,
- new String[] { "modules", "webModule" } );
+ new String[]{ "modules", "webModule" } );
IdeDependency[] deps = this.config.getDeps();
- for (IdeDependency dep : deps) {
- updateApplicationXml(applicationXmlDom, modulemapsXmlDom, dep);
+ for ( IdeDependency dep : deps )
+ {
+ updateApplicationXml( applicationXmlDom, modulemapsXmlDom, dep );
}
removeUnusedEntries( applicationXmlDom, modulemapsXmlDom );
@@ -160,7 +162,7 @@ public class EclipseWtpApplicationXMLWri
/**
* Copy all files from application directory to the target eclipseEar directory.
- *
+ *
* @throws MojoExecutionException wenn an error occures during file copieing
*/
private void copyApplicationFiles()
@@ -168,9 +170,8 @@ public class EclipseWtpApplicationXMLWri
{
try
{
- File applicationDirectory =
- new File( this.config.getEclipseProjectDirectory(), "src" + File.separator + "main" + File.separator
- + "application" );
+ File applicationDirectory = new File( this.config.getEclipseProjectDirectory(),
+ "src" + File.separator + "main" + File.separator + "application" );
File eclipseApplicationDirectory =
new File( this.config.getEclipseProjectDirectory(), "target" + File.separator + "eclipseEar" );
copyDirectoryStructure( applicationDirectory, eclipseApplicationDirectory );
@@ -187,7 +188,7 @@ public class EclipseWtpApplicationXMLWri
* <li>It will include empty directories.
* <li>The <code>sourceDirectory</code> must exists.
* </ul>
- *
+ *
* @param sourceDirectory
* @param destinationDirectory
* @throws IOException
@@ -204,31 +205,36 @@ public class EclipseWtpApplicationXMLWri
String sourcePath = sourceDirectory.getAbsolutePath();
- for (File file : files) {
+ for ( File file : files )
+ {
String dest = file.getAbsolutePath();
- dest = dest.substring(sourcePath.length() + 1);
+ dest = dest.substring( sourcePath.length() + 1 );
- File destination = new File(destinationDirectory, dest);
+ File destination = new File( destinationDirectory, dest );
- if (file.isFile()) {
+ if ( file.isFile() )
+ {
destination = destination.getParentFile();
- FileUtils.copyFileToDirectory(file, destination);
- } else if (file.isDirectory() && !file.getName().equals(".svn") && !file.getName().equals("CVS")) {
- if (!destination.exists() && !destination.mkdirs()) {
- throw new IOException("Could not create destination directory '" + destination.getAbsolutePath()
- + "'.");
+ FileUtils.copyFileToDirectory( file, destination );
+ }
+ else if ( file.isDirectory() && !file.getName().equals( ".svn" ) && !file.getName().equals( "CVS" ) )
+ {
+ if ( !destination.exists() && !destination.mkdirs() )
+ {
+ throw new IOException(
+ "Could not create destination directory '" + destination.getAbsolutePath() + "'." );
}
- copyDirectoryStructure(file, destination);
+ copyDirectoryStructure( file, destination );
}
}
}
/**
* there is no existing application.xml file so create a new one.
- *
+ *
* @return the domtree representing the contents of application.xml
*/
private Xpp3Dom createNewApplicationXml()
@@ -260,7 +266,7 @@ public class EclipseWtpApplicationXMLWri
/**
* there is no existing .modulemaps file so create a new one.
- *
+ *
* @return the domtree representing the contents of the .modulemaps file
*/
private Xpp3Dom createNewModulemaps()
@@ -270,25 +276,28 @@ public class EclipseWtpApplicationXMLWri
result.setAttribute( EclipseWtpApplicationXMLWriter.XMLNS_XMI, "http://www.omg.org/XMI" );
result.setAttribute( EclipseWtpApplicationXMLWriter.XMLNS_APPLICATION, "application.xmi" );
result.setAttribute( EclipseWtpApplicationXMLWriter.XMLNS_MODULEMAP, "modulemap.xmi" );
- result.setAttribute( EclipseWtpApplicationXMLWriter.XMI_ID, "EARProjectMap_" + System.identityHashCode( this ) );
+ result.setAttribute( EclipseWtpApplicationXMLWriter.XMI_ID,
+ "EARProjectMap_" + System.identityHashCode( this ) );
return result;
}
/**
* find an existing module entry in the application.xml file by looking up the id in the modulemaps file and then
* using that to locate the entry in the application.xml file.
- *
+ *
* @param applicationXmlDom application.xml dom tree
- * @param mapping .modulemaps dom tree
+ * @param mapping .modulemaps dom tree
* @return dom tree representing the module
*/
private Xpp3Dom findModuleInApplicationXml( Xpp3Dom applicationXmlDom, Xpp3Dom mapping )
{
String id = getIdFromMapping( mapping );
Xpp3Dom[] children = applicationXmlDom.getChildren();
- for (Xpp3Dom aChildren : children) {
- String childId = aChildren.getAttribute(EclipseWtpApplicationXMLWriter.ID);
- if (childId != null && childId.equals(id)) {
+ for ( Xpp3Dom aChildren : children )
+ {
+ String childId = aChildren.getAttribute( EclipseWtpApplicationXMLWriter.ID );
+ if ( childId != null && childId.equals( id ) )
+ {
return aChildren;
}
}
@@ -297,8 +306,8 @@ public class EclipseWtpApplicationXMLWri
/**
* find an artifact in the modulemaps dom tree, if it is missing create a new entry in the modulemaps dom tree.
- *
- * @param dependency dependency to find
+ *
+ * @param dependency dependency to find
* @param modulemapXmlDom dom-tree of modulemaps
* @return dom-tree representing the artifact
*/
@@ -309,27 +318,27 @@ public class EclipseWtpApplicationXMLWri
for ( int index = 0; index < children.length; index++ )
{
if ( children[index].getAttribute( EclipseWtpApplicationXMLWriter.MODULEMAPS_PROJECT_NAME ).equals(
- dependency.getEclipseProjectName() ) )
+ dependency.getEclipseProjectName() ) )
{
if ( ( dependency.getType().equals( Constants.PROJECT_PACKAGING_EJB ) || dependency.getType().equals(
- "ejb3" ) )
- && children[index].getName().equals( EclipseWtpApplicationXMLWriter.MODULEMAPS_MAPPINGS )
+ "ejb3" ) ) && children[index].getName().equals( EclipseWtpApplicationXMLWriter.MODULEMAPS_MAPPINGS )
&& children[index].getChild( EclipseWtpApplicationXMLWriter.APPLICATION_XML_MODULE ).getAttribute(
- EclipseWtpApplicationXMLWriter.XMI_TYPE ).equals(
- EclipseWtpApplicationXMLWriter.MODULEMAPS_APPLICATION_EJB_MODULE ) )
+ EclipseWtpApplicationXMLWriter.XMI_TYPE ).equals(
+ EclipseWtpApplicationXMLWriter.MODULEMAPS_APPLICATION_EJB_MODULE ) )
{
return children[index];
}
else if ( dependency.getType().equals( Constants.PROJECT_PACKAGING_WAR )
&& children[index].getName().equals( EclipseWtpApplicationXMLWriter.MODULEMAPS_MAPPINGS )
&& children[index].getChild( EclipseWtpApplicationXMLWriter.APPLICATION_XML_MODULE ).getAttribute(
- EclipseWtpApplicationXMLWriter.XMI_TYPE ).equals(
- EclipseWtpApplicationXMLWriter.MODULEMAPS_APPLICATION_WEB_MODULE ) )
+ EclipseWtpApplicationXMLWriter.XMI_TYPE ).equals(
+ EclipseWtpApplicationXMLWriter.MODULEMAPS_APPLICATION_WEB_MODULE ) )
{
return children[index];
}
else if ( dependency.getType().equals( Constants.PROJECT_PACKAGING_JAR )
- && children[index].getName().equals( EclipseWtpApplicationXMLWriter.MODULEMAPS_UTILITY_JARMAPPINGS ) )
+ && children[index].getName().equals(
+ EclipseWtpApplicationXMLWriter.MODULEMAPS_UTILITY_JARMAPPINGS ) )
{
return children[index];
}
@@ -377,8 +386,8 @@ public class EclipseWtpApplicationXMLWri
utilityJARMapping.setAttribute( EclipseWtpApplicationXMLWriter.XMI_ID, "UtilityJARMapping_" + id );
utilityJARMapping.setAttribute( EclipseWtpApplicationXMLWriter.MODULEMAPS_PROJECT_NAME,
dependency.getEclipseProjectName() );
- utilityJARMapping.setAttribute( EclipseWtpApplicationXMLWriter.URI, dependency.getEclipseProjectName()
- + ".jar" );
+ utilityJARMapping.setAttribute( EclipseWtpApplicationXMLWriter.URI,
+ dependency.getEclipseProjectName() + ".jar" );
modulemapXmlDom.addChild( utilityJARMapping );
return utilityJARMapping;
}
@@ -386,7 +395,7 @@ public class EclipseWtpApplicationXMLWri
/**
* get the id from the href of a modulemap.
- *
+ *
* @param mapping the dom-tree of modulemaps
* @return module identifier
*/
@@ -403,7 +412,7 @@ public class EclipseWtpApplicationXMLWri
/**
* read an xml file (application.xml or .modulemaps).
- *
+ *
* @param xmlFile an xmlfile
* @return dom-tree representing the file contents
*/
@@ -429,7 +438,7 @@ public class EclipseWtpApplicationXMLWri
/**
* mark the domtree entry as handled (all not handled ones will be deleted).
- *
+ *
* @param xpp3Dom dom element to mark handled
*/
private void handled( Xpp3Dom xpp3Dom )
@@ -452,29 +461,37 @@ public class EclipseWtpApplicationXMLWri
/**
* delete all unused entries from the dom-trees.
- *
+ *
* @param applicationXmlDom dom-tree of application.xml
- * @param modulemapsXmlDom dom-tree of modulemaps
+ * @param modulemapsXmlDom dom-tree of modulemaps
*/
private void removeUnusedEntries( Xpp3Dom applicationXmlDom, Xpp3Dom modulemapsXmlDom )
{
- for (Xpp3Dom aModulemapsXmlDomChildren : this.modulemapsXmlDomChildren) {
- if (aModulemapsXmlDomChildren != null) {
+ for ( Xpp3Dom aModulemapsXmlDomChildren : this.modulemapsXmlDomChildren )
+ {
+ if ( aModulemapsXmlDomChildren != null )
+ {
Xpp3Dom[] newModulemapsXmlDomChildren = modulemapsXmlDom.getChildren();
- for (int newIndex = 0; newIndex < newModulemapsXmlDomChildren.length; newIndex++) {
- if (newModulemapsXmlDomChildren[newIndex] == aModulemapsXmlDomChildren) {
- modulemapsXmlDom.removeChild(newIndex);
+ for ( int newIndex = 0; newIndex < newModulemapsXmlDomChildren.length; newIndex++ )
+ {
+ if ( newModulemapsXmlDomChildren[newIndex] == aModulemapsXmlDomChildren )
+ {
+ modulemapsXmlDom.removeChild( newIndex );
break;
}
}
}
}
- for (Xpp3Dom anApplicationXmlDomChildren : this.applicationXmlDomChildren) {
- if (anApplicationXmlDomChildren != null) {
+ for ( Xpp3Dom anApplicationXmlDomChildren : this.applicationXmlDomChildren )
+ {
+ if ( anApplicationXmlDomChildren != null )
+ {
Xpp3Dom[] newApplicationXmlDomChildren = applicationXmlDom.getChildren();
- for (int newIndex = 0; newIndex < newApplicationXmlDomChildren.length; newIndex++) {
- if (newApplicationXmlDomChildren[newIndex] == anApplicationXmlDomChildren) {
- applicationXmlDom.removeChild(newIndex);
+ for ( int newIndex = 0; newIndex < newApplicationXmlDomChildren.length; newIndex++ )
+ {
+ if ( newApplicationXmlDomChildren[newIndex] == anApplicationXmlDomChildren )
+ {
+ applicationXmlDom.removeChild( newIndex );
break;
}
}
@@ -486,15 +503,15 @@ public class EclipseWtpApplicationXMLWri
* update the application.xml and the .modulemaps file for a specified dependency.all WAR an EJB dependencies will
* go in both files all others only in the modulemaps files. Webapplications contextroots are corrected to the
* contextRoot specified in the pom.
- *
+ *
* @param applicationXmlDom dom-tree of application.xml
- * @param modulemapXmlDom dom-tree of modulemaps
- * @param dependency the eclipse dependency to handle
+ * @param modulemapXmlDom dom-tree of modulemaps
+ * @param dependency the eclipse dependency to handle
*/
private void updateApplicationXml( Xpp3Dom applicationXmlDom, Xpp3Dom modulemapXmlDom, IdeDependency dependency )
{
- if ( dependency.isTestDependency() || dependency.isProvided()
- || dependency.isSystemScopedOutsideProject( this.config.getProject() ) )
+ if ( dependency.isTestDependency() || dependency.isProvided() || dependency.isSystemScopedOutsideProject(
+ this.config.getProject() ) )
{
return;
}
@@ -540,19 +557,17 @@ public class EclipseWtpApplicationXMLWri
{
handled( module );
module.getChild( EclipseWtpApplicationXMLWriter.APPLICATION_XML_WEB ).getChild(
- EclipseWtpApplicationXMLWriter.APPLICATION_XML_WEB_URI ).setValue(
- dependency.getEclipseProjectName()
- + ".war" );
+ EclipseWtpApplicationXMLWriter.APPLICATION_XML_WEB_URI ).setValue(
+ dependency.getEclipseProjectName() + ".war" );
module.getChild( EclipseWtpApplicationXMLWriter.APPLICATION_XML_WEB ).getChild(
- EclipseWtpApplicationXMLWriter.APPLICATION_XML_CONTEXT_ROOT ).setValue(
- contextRootInPom );
+ EclipseWtpApplicationXMLWriter.APPLICATION_XML_CONTEXT_ROOT ).setValue( contextRootInPom );
}
}
}
/**
* Find the contextRoot specified in the pom and convert it into contectroot for the application.xml.
- *
+ *
* @param dependency the artifact to search
* @return string with the context root
*/
@@ -560,13 +575,15 @@ public class EclipseWtpApplicationXMLWri
{
String artifactId = dependency.getArtifactId();
String groupId = dependency.getGroupId();
- for (Xpp3Dom webModulesFromPom : this.webModulesFromPoms) {
- Xpp3Dom webGroupId = webModulesFromPom.getChild("groupId");
- Xpp3Dom webArtifactId = webModulesFromPom.getChild("artifactId");
- Xpp3Dom webContextRoot = webModulesFromPom.getChild("contextRoot");
+ for ( Xpp3Dom webModulesFromPom : this.webModulesFromPoms )
+ {
+ Xpp3Dom webGroupId = webModulesFromPom.getChild( "groupId" );
+ Xpp3Dom webArtifactId = webModulesFromPom.getChild( "artifactId" );
+ Xpp3Dom webContextRoot = webModulesFromPom.getChild( "contextRoot" );
- if (webContextRoot != null && webArtifactId != null && webArtifactId.getValue().equals(artifactId)
- && webGroupId != null && webGroupId.getValue().equals(groupId)) {
+ if ( webContextRoot != null && webArtifactId != null && webArtifactId.getValue().equals( artifactId )
+ && webGroupId != null && webGroupId.getValue().equals( groupId ) )
+ {
return webContextRoot.getValue();
}
}
@@ -576,8 +593,8 @@ public class EclipseWtpApplicationXMLWri
/**
* write back a domtree to a xmlfile and use the pretty print for it so that it is human readable.
- *
- * @param xmlFile file to write to
+ *
+ * @param xmlFile file to write to
* @param xmlDomTree dom-tree to write
* @throws MojoExecutionException if the file could not be written
*/
Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpComponentWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpComponentWriter.java?rev=1517827&r1=1517826&r2=1517827&view=diff
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpComponentWriter.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpComponentWriter.java Tue Aug 27 14:16:42 2013
@@ -38,7 +38,7 @@ import org.codehaus.plexus.util.xml.Xpp3
/**
* Creates a .settings folder for Eclipse WTP 1.x release and writes out the configuration under it.
- *
+ *
* @author <a href="mailto:rahul.thakur.xdev@gmail.com">Rahul Thakur</a>
* @author <a href="mailto:fgiust@apache.org">Fabrizio Giustina</a>
* @version $Id$
@@ -59,7 +59,7 @@ public class EclipseWtpComponentWriter
/**
* File name where the WTP component settings will be stored for our Eclipse Project.
- *
+ *
* @return <code>.component</code>
*/
protected String getComponentFileName()
@@ -69,7 +69,7 @@ public class EclipseWtpComponentWriter
/**
* Version number added to component configuration.
- *
+ *
* @return <code>1.0</code>
*/
protected String getProjectVersion()
@@ -91,13 +91,13 @@ public class EclipseWtpComponentWriter
Writer w;
try
{
- w =
- new OutputStreamWriter( new FileOutputStream( new File( settingsDir, getComponentFileName() ) ),
+ w = new OutputStreamWriter( new FileOutputStream( new File( settingsDir, getComponentFileName() ) ),
"UTF-8" );
}
catch ( IOException ex )
{
- throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
+ throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ),
+ ex ); //$NON-NLS-1$
}
// create a .component file and write out to it
@@ -111,7 +111,7 @@ public class EclipseWtpComponentWriter
/**
* Writes out the module type settings for a Web Tools Project to a component file.
- *
+ *
* @param writer
* @param packaging
* @param buildOutputDirectory
@@ -141,10 +141,10 @@ public class EclipseWtpComponentWriter
{
target = "/WEB-INF/classes"; //$NON-NLS-1$
- File warSourceDirectory =
- new File( IdeUtils.getPluginSetting( config.getProject(), JeeUtils.ARTIFACT_MAVEN_WAR_PLUGIN,
- "warSourceDirectory", //$NON-NLS-1$
- config.getProject().getBasedir() + "/src/main/webapp" ) ); //$NON-NLS-1$
+ File warSourceDirectory = new File(
+ IdeUtils.getPluginSetting( config.getProject(), JeeUtils.ARTIFACT_MAVEN_WAR_PLUGIN,
+ "warSourceDirectory", //$NON-NLS-1$
+ config.getProject().getBasedir() + "/src/main/webapp" ) ); //$NON-NLS-1$
writeContextRoot( writer );
@@ -158,14 +158,15 @@ public class EclipseWtpComponentWriter
// add web resources over the top of the war source directory
Xpp3Dom[] webResources =
IdeUtils.getPluginConfigurationDom( config.getProject(), JeeUtils.ARTIFACT_MAVEN_WAR_PLUGIN,
- new String[] { "webResources", "resource" } );
- for (Xpp3Dom webResource : webResources) {
- File webResourceDirectory = new File(webResource.getChild("directory").getValue());
- writer.startElement(ELT_WB_RESOURCE);
- writer.addAttribute(ATTR_DEPLOY_PATH, "/"); //$NON-NLS-1$
- writer.addAttribute(ATTR_SOURCE_PATH,
- IdeUtils.toRelativeAndFixSeparator(config.getEclipseProjectDirectory(),
- webResourceDirectory, false));
+ new String[]{ "webResources", "resource" } );
+ for ( Xpp3Dom webResource : webResources )
+ {
+ File webResourceDirectory = new File( webResource.getChild( "directory" ).getValue() );
+ writer.startElement( ELT_WB_RESOURCE );
+ writer.addAttribute( ATTR_DEPLOY_PATH, "/" ); //$NON-NLS-1$
+ writer.addAttribute( ATTR_SOURCE_PATH,
+ IdeUtils.toRelativeAndFixSeparator( config.getEclipseProjectDirectory(),
+ webResourceDirectory, false ) );
writer.endElement();
}
@@ -203,13 +204,15 @@ public class EclipseWtpComponentWriter
}
- for (EclipseSourceDir dir : sourceDirs) {
+ for ( EclipseSourceDir dir : sourceDirs )
+ {
// test src/resources are not added to wtpmodules
- if (!dir.isTest()) {
+ if ( !dir.isTest() )
+ {
// <wb-resource deploy-path="/" source-path="/src/java" />
- writer.startElement(ELT_WB_RESOURCE);
- writer.addAttribute(ATTR_DEPLOY_PATH, target);
- writer.addAttribute(ATTR_SOURCE_PATH, dir.getPath());
+ writer.startElement( ELT_WB_RESOURCE );
+ writer.addAttribute( ATTR_DEPLOY_PATH, target );
+ writer.addAttribute( ATTR_SOURCE_PATH, dir.getPath() );
writer.endElement();
}
}
Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpFacetsWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpFacetsWriter.java?rev=1517827&r1=1517826&r2=1517827&view=diff
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpFacetsWriter.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpFacetsWriter.java Tue Aug 27 14:16:42 2013
@@ -36,7 +36,7 @@ import org.codehaus.plexus.util.xml.XMLW
/**
* Creates a .settings folder for Eclipse WTP 1.x release and writes out the configuration under it.
- *
+ *
* @author <a href="mailto:rahul.thakur.xdev@gmail.com">Rahul Thakur</a>
* @author <a href="mailto:fgiust@apache.org">Fabrizio Giustina</a>
* @version $Id$
@@ -45,7 +45,8 @@ public class EclipseWtpFacetsWriter
extends AbstractWtpResourceWriter
{
- private static final String FACET_COM_IBM_WEBSPHERE_COEXISTENCE_EAR = "com.ibm.websphere.coexistence.ear"; //$NON-NLS-1$
+ private static final String FACET_COM_IBM_WEBSPHERE_COEXISTENCE_EAR = "com.ibm.websphere.coexistence.ear";
+ //$NON-NLS-1$
private static final String FACET_COM_IBM_WEBSPHERE_EXTENDED_EAR = "com.ibm.websphere.extended.ear"; //$NON-NLS-1$
@@ -101,7 +102,8 @@ public class EclipseWtpFacetsWriter
}
catch ( IOException ex )
{
- throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
+ throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ),
+ ex ); //$NON-NLS-1$
}
XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null );
writeModuleTypeFacetCore( writer, packaging );
@@ -110,7 +112,7 @@ public class EclipseWtpFacetsWriter
/**
* Writes out the facet info for a faceted-project based on the packaging.
- *
+ *
* @param writer
* @param packaging
*/
@@ -131,13 +133,14 @@ public class EclipseWtpFacetsWriter
servletVersion = JeeUtils.resolveServletVersion( config.getProject() );
}
writeFacetInstalledElement( writer, FACET_JST_WEB, servletVersion ); // installed
- writeFacetInstalledElement( writer, FACET_JST_JAVA, IdeUtils.resolveJavaVersion( config.getProject() ) ); // installed
+ writeFacetInstalledElement( writer, FACET_JST_JAVA,
+ IdeUtils.resolveJavaVersion( config.getProject() ) ); // installed
}
else if ( Constants.PROJECT_PACKAGING_EJB.equalsIgnoreCase( packaging ) ) //$NON-NLS-1$
{
writeFacetFixedElement( writer, FACET_JST_JAVA ); // fixed
writeFacetFixedElement( writer, FACET_JST_EJB ); // fixed
-
+
String ejbVersion;
if ( config.getJeeVersion() != null )
{
@@ -148,7 +151,8 @@ public class EclipseWtpFacetsWriter
ejbVersion = JeeUtils.resolveEjbVersion( config.getProject() );
}
writeFacetInstalledElement( writer, FACET_JST_EJB, ejbVersion ); // installed
- writeFacetInstalledElement( writer, FACET_JST_JAVA, IdeUtils.resolveJavaVersion( config.getProject() ) ); // installed
+ writeFacetInstalledElement( writer, FACET_JST_JAVA,
+ IdeUtils.resolveJavaVersion( config.getProject() ) ); // installed
}
else if ( Constants.PROJECT_PACKAGING_EAR.equalsIgnoreCase( packaging ) ) //$NON-NLS-1$
{
@@ -182,7 +186,8 @@ public class EclipseWtpFacetsWriter
writeFacetFixedElement( writer, FACET_JST_JAVA ); // fixed
writeFacetFixedElement( writer, FACET_JST_UTILITY ); // fixed
writeFacetInstalledElement( writer, FACET_JST_UTILITY, "1.0" ); //$NON-NLS-1$
- writeFacetInstalledElement( writer, FACET_JST_JAVA, IdeUtils.resolveJavaVersion( config.getProject() ) ); // installed
+ writeFacetInstalledElement( writer, FACET_JST_JAVA,
+ IdeUtils.resolveJavaVersion( config.getProject() ) ); // installed
// installed
}
@@ -194,7 +199,7 @@ public class EclipseWtpFacetsWriter
/**
* Writes facet <code>fixed</code> element with attribute <code>facet</code> set to the value of argument
* <code>facetName</code>.
- *
+ *
* @param writer
* @param facetName
*/
@@ -209,7 +214,7 @@ public class EclipseWtpFacetsWriter
* Writes a facet <code>installed</code> element with attribute <code>facet</code> set to the value of argument
* <code>facetName</code>, and attribute <code>version</code> set to the value of argument <code>facetVersion</code>
* .
- *
+ *
* @param writer
* @param facetName
* @param facetVersion
@@ -224,7 +229,7 @@ public class EclipseWtpFacetsWriter
/**
* Writes out any additional project facets specified in the plugin configuration
- *
+ *
* @param writer
* @param packaging
*/
@@ -235,12 +240,13 @@ public class EclipseWtpFacetsWriter
return;
}
- for (Object o : config.getProjectFacets().entrySet()) {
+ for ( Object o : config.getProjectFacets().entrySet() )
+ {
Entry facetEntry = (Entry) o;
- writer.startElement(ELT_INSTALLED);
- writer.addAttribute(ATTR_FACET, (String) facetEntry.getKey());
- writer.addAttribute(ATTR_VERSION, (String) facetEntry.getValue());
+ writer.startElement( ELT_INSTALLED );
+ writer.addAttribute( ATTR_FACET, (String) facetEntry.getKey() );
+ writer.addAttribute( ATTR_VERSION, (String) facetEntry.getValue() );
writer.endElement(); // installed
}
}
Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java?rev=1517827&r1=1517826&r2=1517827&view=diff
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/AbstractIdeSupportMojo.java Tue Aug 27 14:16:42 2013
@@ -67,7 +67,7 @@ import org.codehaus.plexus.logging.Logge
* Abstract base plugin which takes care of the common stuff usually needed by maven IDE plugins. A plugin extending
* AbstractIdeSupportMojo should implement the <code>setup()</code> and <code>writeConfiguration()</code> methods, plus
* the getters needed to get the various configuration flags and required components. The lifecycle:
- *
+ * <p/>
* <pre>
* *** calls setup() where you can configure your specific stuff and stop the mojo from execute if appropriate ***
* - manually resolve project dependencies, NOT failing if a dependency is missing
@@ -76,7 +76,7 @@ import org.codehaus.plexus.logging.Logge
* *** calls writeConfiguration(), passing the list of resolved referenced dependencies ***
* - report the list of missing sources or just tell how to turn this feature on if the flag was disabled
* </pre>
- *
+ *
* @author Fabrizio Giustina
* @version $Id$
*/
@@ -87,7 +87,7 @@ public abstract class AbstractIdeSupport
/**
* The project whose project files to create.
- *
+ *
* @parameter expression="${project}"
* @required
* @readonly
@@ -96,7 +96,7 @@ public abstract class AbstractIdeSupport
/**
* The currently executed project (can be a reactor project).
- *
+ *
* @parameter expression="${executedProject}"
* @readonly
*/
@@ -104,14 +104,14 @@ public abstract class AbstractIdeSupport
/**
* The project packaging.
- *
+ *
* @parameter expression="${project.packaging}"
*/
protected String packaging;
/**
* Artifact factory, needed to download source jars for inclusion in classpath.
- *
+ *
* @component role="org.apache.maven.artifact.factory.ArtifactFactory"
* @required
* @readonly
@@ -120,7 +120,7 @@ public abstract class AbstractIdeSupport
/**
* Artifact resolver, needed to download source jars for inclusion in classpath.
- *
+ *
* @component role="org.apache.maven.artifact.resolver.ArtifactResolver"
* @required
* @readonly
@@ -129,7 +129,7 @@ public abstract class AbstractIdeSupport
/**
* Artifact collector, needed to resolve dependencies.
- *
+ *
* @component role="org.apache.maven.artifact.resolver.ArtifactCollector"
* @required
* @readonly
@@ -143,14 +143,14 @@ public abstract class AbstractIdeSupport
/**
* The runtime information for Maven, used to retrieve Maven's version number.
- *
+ *
* @component
*/
private RuntimeInformation runtimeInformation;
/**
* Remote repositories which will be searched for source attachments.
- *
+ *
* @parameter expression="${project.remoteArtifactRepositories}"
* @required
* @readonly
@@ -159,7 +159,7 @@ public abstract class AbstractIdeSupport
/**
* Local maven repository.
- *
+ *
* @parameter expression="${localRepository}"
* @required
* @readonly
@@ -168,7 +168,7 @@ public abstract class AbstractIdeSupport
/**
* If the executed project is a reactor project, this will contains the full list of projects in the reactor.
- *
+ *
* @parameter expression="${reactorProjects}"
* @required
* @readonly
@@ -177,7 +177,7 @@ public abstract class AbstractIdeSupport
/**
* Skip the operation when true.
- *
+ *
* @parameter expression="${eclipse.skip}" default-value="false"
*/
private boolean skip;
@@ -188,7 +188,7 @@ public abstract class AbstractIdeSupport
* status cache is mantained. With versions 2.6+ of the plugin to reset this cache run
* <code>mvn eclipse:remove-cache</code>, or use the <code>forceRecheck</code> option with versions. With older
* versions delete the file <code>mvn-eclipse-cache.properties</code> in the target directory.
- *
+ *
* @parameter expression="${downloadSources}"
*/
protected boolean downloadSources;
@@ -199,7 +199,7 @@ public abstract class AbstractIdeSupport
* a status cache is mantained. With versions 2.6+ of the plugin to reset this cache run
* <code>mvn eclipse:remove-cache</code>, or use the <code>forceRecheck</code> option with versions. With older
* versions delete the file <code>mvn-eclipse-cache.properties</code> in the target directory.
- *
+ *
* @parameter expression="${downloadJavadocs}"
*/
protected boolean downloadJavadocs;
@@ -209,7 +209,7 @@ public abstract class AbstractIdeSupport
* false. When this flag is <code>true</code> 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.
- *
+ *
* @parameter expression="${forceRecheck}"
*/
protected boolean forceRecheck;
@@ -221,7 +221,7 @@ public abstract class AbstractIdeSupport
/**
* Getter for <code>artifactMetadataSource</code>.
- *
+ *
* @return Returns the artifactMetadataSource.
*/
public ArtifactMetadataSource getArtifactMetadataSource()
@@ -231,7 +231,7 @@ public abstract class AbstractIdeSupport
/**
* Setter for <code>artifactMetadataSource</code>.
- *
+ *
* @param artifactMetadataSource The artifactMetadataSource to set.
*/
public void setArtifactMetadataSource( ArtifactMetadataSource artifactMetadataSource )
@@ -241,7 +241,7 @@ public abstract class AbstractIdeSupport
/**
* Getter for <code>project</code>.
- *
+ *
* @return Returns the project.
*/
public MavenProject getProject()
@@ -251,7 +251,7 @@ public abstract class AbstractIdeSupport
/**
* Setter for <code>project</code>.
- *
+ *
* @param project The project to set.
*/
public void setProject( MavenProject project )
@@ -261,7 +261,7 @@ public abstract class AbstractIdeSupport
/**
* Getter for <code>reactorProjects</code>.
- *
+ *
* @return Returns the reactorProjects.
*/
public List getReactorProjects()
@@ -271,7 +271,7 @@ public abstract class AbstractIdeSupport
/**
* Setter for <code>reactorProjects</code>.
- *
+ *
* @param reactorProjects The reactorProjects to set.
*/
public void setReactorProjects( List reactorProjects )
@@ -281,7 +281,7 @@ public abstract class AbstractIdeSupport
/**
* Getter for <code>remoteArtifactRepositories</code>.
- *
+ *
* @return Returns the remoteArtifactRepositories.
*/
public List getRemoteArtifactRepositories()
@@ -291,7 +291,7 @@ public abstract class AbstractIdeSupport
/**
* Setter for <code>remoteArtifactRepositories</code>.
- *
+ *
* @param remoteArtifactRepositories The remoteArtifactRepositories to set.
*/
public void setRemoteArtifactRepositories( List remoteArtifactRepositories )
@@ -301,7 +301,7 @@ public abstract class AbstractIdeSupport
/**
* Getter for <code>artifactFactory</code>.
- *
+ *
* @return Returns the artifactFactory.
*/
public ArtifactFactory getArtifactFactory()
@@ -311,7 +311,7 @@ public abstract class AbstractIdeSupport
/**
* Setter for <code>artifactFactory</code>.
- *
+ *
* @param artifactFactory The artifactFactory to set.
*/
public void setArtifactFactory( ArtifactFactory artifactFactory )
@@ -321,7 +321,7 @@ public abstract class AbstractIdeSupport
/**
* Getter for <code>artifactResolver</code>.
- *
+ *
* @return Returns the artifactResolver.
*/
public ArtifactResolver getArtifactResolver()
@@ -331,7 +331,7 @@ public abstract class AbstractIdeSupport
/**
* Setter for <code>artifactResolver</code>.
- *
+ *
* @param artifactResolver The artifactResolver to set.
*/
public void setArtifactResolver( ArtifactResolver artifactResolver )
@@ -341,7 +341,7 @@ public abstract class AbstractIdeSupport
/**
* Getter for <code>executedProject</code>.
- *
+ *
* @return Returns the executedProject.
*/
public MavenProject getExecutedProject()
@@ -351,7 +351,7 @@ public abstract class AbstractIdeSupport
/**
* Setter for <code>executedProject</code>.
- *
+ *
* @param executedProject The executedProject to set.
*/
public void setExecutedProject( MavenProject executedProject )
@@ -361,7 +361,7 @@ public abstract class AbstractIdeSupport
/**
* Getter for <code>localRepository</code>.
- *
+ *
* @return Returns the localRepository.
*/
public ArtifactRepository getLocalRepository()
@@ -371,7 +371,7 @@ public abstract class AbstractIdeSupport
/**
* Setter for <code>localRepository</code>.
- *
+ *
* @param localRepository The localRepository to set.
*/
public void setLocalRepository( ArtifactRepository localRepository )
@@ -381,7 +381,7 @@ public abstract class AbstractIdeSupport
/**
* Getter for <code>downloadJavadocs</code>.
- *
+ *
* @return Returns the downloadJavadocs.
*/
public boolean getDownloadJavadocs()
@@ -391,7 +391,7 @@ public abstract class AbstractIdeSupport
/**
* Setter for <code>downloadJavadocs</code>.
- *
+ *
* @param downloadJavadoc The downloadJavadocs to set.
*/
public void setDownloadJavadocs( boolean downloadJavadoc )
@@ -401,7 +401,7 @@ public abstract class AbstractIdeSupport
/**
* Getter for <code>downloadSources</code>.
- *
+ *
* @return Returns the downloadSources.
*/
public boolean getDownloadSources()
@@ -411,7 +411,7 @@ public abstract class AbstractIdeSupport
/**
* Setter for <code>downloadSources</code>.
- *
+ *
* @param downloadSources The downloadSources to set.
*/
public void setDownloadSources( boolean downloadSources )
@@ -432,14 +432,14 @@ public abstract class AbstractIdeSupport
/**
* return <code>false</code> if projects available in a reactor build should be considered normal dependencies,
* <code>true</code> if referenced project will be linked and not need artifact resolution.
- *
+ *
* @return <code>true</code> if referenced project will be linked and not need artifact resolution
*/
protected abstract boolean getUseProjectReferences();
/**
* Hook for preparation steps before the actual plugin execution.
- *
+ *
* @return <code>true</code> if execution should continue or <code>false</code> if not.
* @throws MojoExecutionException generic mojo exception
*/
@@ -448,7 +448,7 @@ public abstract class AbstractIdeSupport
/**
* Main plugin method where dependencies should be processed in order to generate IDE configuration files.
- *
+ *
* @param deps list of <code>IdeDependency</code> objects, with artifacts, sources and javadocs already resolved
* @throws MojoExecutionException generic mojo exception
*/
@@ -517,9 +517,9 @@ public abstract class AbstractIdeSupport
* Resolve project dependencies. Manual resolution is needed in order to avoid resolution of multiproject artifacts
* (if projects will be linked each other an installed jar is not needed) and to avoid a failure when a jar is
* missing.
- *
- * @throws MojoExecutionException if dependencies can't be resolved
+ *
* @return resolved IDE dependencies, with attached jars for non-reactor dependencies
+ * @throws MojoExecutionException if dependencies can't be resolved
*/
protected IdeDependency[] doDependencyResolution()
throws MojoExecutionException
@@ -538,9 +538,8 @@ public abstract class AbstractIdeSupport
if ( deps != null )
{
- Map managedVersions =
- createManagedVersionMap( getArtifactFactory(), project.getId(),
- project.getDependencyManagement() );
+ Map managedVersions = createManagedVersionMap( getArtifactFactory(), project.getId(),
+ project.getDependencyManagement() );
ArtifactResolutionResult artifactResolutionResult;
@@ -565,9 +564,8 @@ public abstract class AbstractIdeSupport
{
getLog().debug( e.getMessage(), e );
getLog().error(
- Messages.getString( "AbstractIdeSupportMojo.artifactresolution", new Object[] { //$NON-NLS-1$
- e.getGroupId(), e.getArtifactId(), e.getVersion(),
- e.getMessage() } ) );
+ Messages.getString( "AbstractIdeSupportMojo.artifactresolution", new Object[]{ //$NON-NLS-1$
+ e.getGroupId(), e.getArtifactId(), e.getVersion(), e.getMessage() } ) );
// if we are here artifactResolutionResult is null, create a project without dependencies but
// don't fail
@@ -579,44 +577,51 @@ public abstract class AbstractIdeSupport
// keep track of added reactor projects in order to avoid duplicates
Set emittedReactorProjectId = new HashSet();
- for (Object o : artifactResolutionResult.getArtifactResolutionNodes()) {
+ for ( Object o : artifactResolutionResult.getArtifactResolutionNodes() )
+ {
ResolutionNode node = (ResolutionNode) o;
int dependencyDepth = node.getDepth();
Artifact art = node.getArtifact();
// don't resolve jars for reactor projects
- if (hasToResolveJar(art)) {
- try {
- artifactResolver.resolve(art, node.getRemoteRepositories(), localRepository);
- } catch (ArtifactNotFoundException e) {
- getLog().debug(e.getMessage(), e);
- getLog().warn(
- Messages.getString(
- "AbstractIdeSupportMojo.artifactdownload", new Object[]{ //$NON-NLS-1$
- e.getGroupId(), e.getArtifactId(), e.getVersion(),
- e.getMessage()}));
- } catch (ArtifactResolutionException e) {
- getLog().debug(e.getMessage(), e);
- getLog().warn(
- Messages.getString(
- "AbstractIdeSupportMojo.artifactresolution", new Object[]{ //$NON-NLS-1$
- e.getGroupId(), e.getArtifactId(), e.getVersion(),
- e.getMessage()}));
+ if ( hasToResolveJar( art ) )
+ {
+ try
+ {
+ artifactResolver.resolve( art, node.getRemoteRepositories(), localRepository );
+ }
+ catch ( ArtifactNotFoundException e )
+ {
+ getLog().debug( e.getMessage(), e );
+ getLog().warn( Messages.getString( "AbstractIdeSupportMojo.artifactdownload",
+ new Object[]{ //$NON-NLS-1$
+ e.getGroupId(), e.getArtifactId(),
+ e.getVersion(), e.getMessage() } ) );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ getLog().debug( e.getMessage(), e );
+ getLog().warn( Messages.getString( "AbstractIdeSupportMojo.artifactresolution",
+ new Object[]{ //$NON-NLS-1$
+ e.getGroupId(), e.getArtifactId(),
+ e.getVersion(), e.getMessage() } ) );
}
}
boolean includeArtifact = true;
- if (getExcludes() != null) {
+ if ( getExcludes() != null )
+ {
String artifactFullId = art.getGroupId() + ":" + art.getArtifactId();
- if (getExcludes().contains(artifactFullId)) {
- getLog().info("excluded: " + artifactFullId);
+ if ( getExcludes().contains( artifactFullId ) )
+ {
+ getLog().info( "excluded: " + artifactFullId );
includeArtifact = false;
}
}
- if (includeArtifact
- && (!(getUseProjectReferences() && isAvailableAsAReactorProject(art)) || emittedReactorProjectId.add(art.getGroupId()
- + '-' + art.getArtifactId()))) {
+ if ( includeArtifact && ( !( getUseProjectReferences() && isAvailableAsAReactorProject( art ) )
+ || emittedReactorProjectId.add( art.getGroupId() + '-' + art.getArtifactId() ) ) )
+ {
// the following doesn't work: art.getArtifactHandler().getPackaging() always returns "jar"
// also
@@ -633,25 +638,34 @@ public abstract class AbstractIdeSupport
// an osgi bundle
boolean isOsgiBundle;
String osgiSymbolicName = null;
- if (art.getFile() != null) {
+ if ( art.getFile() != null )
+ {
JarFile jarFile = null;
- try {
- jarFile = new JarFile(art.getFile(), false, ZipFile.OPEN_READ);
+ try
+ {
+ jarFile = new JarFile( art.getFile(), false, ZipFile.OPEN_READ );
Manifest manifest = jarFile.getManifest();
- if (manifest != null) {
- osgiSymbolicName =
- manifest.getMainAttributes().getValue(
- new Attributes.Name(
- "Bundle-SymbolicName"));
+ if ( manifest != null )
+ {
+ osgiSymbolicName = manifest.getMainAttributes().getValue(
+ new Attributes.Name( "Bundle-SymbolicName" ) );
}
- } catch (IOException e) {
- getLog().info("Unable to read jar manifest from " + art.getFile());
- } finally {
- if (jarFile != null) {
- try {
+ }
+ catch ( IOException e )
+ {
+ getLog().info( "Unable to read jar manifest from " + art.getFile() );
+ }
+ finally
+ {
+ if ( jarFile != null )
+ {
+ try
+ {
jarFile.close();
- } catch (IOException e) {
+ }
+ catch ( IOException e )
+ {
// ignore
}
}
@@ -661,17 +675,18 @@ public abstract class AbstractIdeSupport
isOsgiBundle = osgiSymbolicName != null;
IdeDependency dep =
- new IdeDependency(art.getGroupId(), art.getArtifactId(), art.getVersion(),
- art.getClassifier(), useProjectReference(art),
- Artifact.SCOPE_TEST.equals(art.getScope()),
- Artifact.SCOPE_SYSTEM.equals(art.getScope()),
- Artifact.SCOPE_PROVIDED.equals(art.getScope()),
- art.getArtifactHandler().isAddedToClasspath(), art.getFile(),
- art.getType(), isOsgiBundle, osgiSymbolicName, dependencyDepth,
- getProjectNameForArifact(art));
+ new IdeDependency( art.getGroupId(), art.getArtifactId(), art.getVersion(),
+ art.getClassifier(), useProjectReference( art ),
+ Artifact.SCOPE_TEST.equals( art.getScope() ),
+ Artifact.SCOPE_SYSTEM.equals( art.getScope() ),
+ Artifact.SCOPE_PROVIDED.equals( art.getScope() ),
+ art.getArtifactHandler().isAddedToClasspath(), art.getFile(),
+ art.getType(), isOsgiBundle, osgiSymbolicName, dependencyDepth,
+ getProjectNameForArifact( art ) );
// no duplicate entries allowed. System paths can cause this problem.
- if (!dependencies.contains(dep)) {
- dependencies.add(dep);
+ if ( !dependencies.contains( dep ) )
+ {
+ dependencies.add( dep );
}
}
@@ -695,7 +710,7 @@ public abstract class AbstractIdeSupport
/**
* Find the name of the project as used in eclipse.
- *
+ *
* @param artifact The artifact to find the eclipse name for.
* @return The name os the eclipse project.
*/
@@ -704,7 +719,7 @@ public abstract class AbstractIdeSupport
/**
* Returns the list of project artifacts. Also artifacts generated from referenced projects will be added, but with
* the <code>resolved</code> property set to true.
- *
+ *
* @return list of projects artifacts
* @throws MojoExecutionException if unable to parse dependency versions
*/
@@ -714,46 +729,50 @@ public abstract class AbstractIdeSupport
// [MECLIPSE-388] Don't sort this, the order should be identical to getProject.getDependencies()
Set artifacts = new LinkedHashSet();
- for (Object o : getProject().getDependencies()) {
+ for ( Object o : getProject().getDependencies() )
+ {
Dependency dependency = (Dependency) o;
String groupId = dependency.getGroupId();
String artifactId = dependency.getArtifactId();
VersionRange versionRange;
- try {
- versionRange = VersionRange.createFromVersionSpec(dependency.getVersion());
- } catch (InvalidVersionSpecificationException e) {
+ try
+ {
+ versionRange = VersionRange.createFromVersionSpec( dependency.getVersion() );
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
throw new MojoExecutionException(
- Messages.getString(
- "AbstractIdeSupportMojo.unabletoparseversion", new Object[]{ //$NON-NLS-1$
- dependency.getArtifactId(),
- dependency.getVersion(),
- dependency.getManagementKey(), e.getMessage()}),
- e);
+ Messages.getString( "AbstractIdeSupportMojo.unabletoparseversion", new Object[]{ //$NON-NLS-1$
+ dependency.getArtifactId(), dependency.getVersion(), dependency.getManagementKey(),
+ e.getMessage() } ), e );
}
String type = dependency.getType();
- if (type == null) {
+ if ( type == null )
+ {
type = Constants.PROJECT_PACKAGING_JAR;
}
String classifier = dependency.getClassifier();
boolean optional = dependency.isOptional();
String scope = dependency.getScope();
- if (scope == null) {
+ if ( scope == null )
+ {
scope = Artifact.SCOPE_COMPILE;
}
Artifact art =
- getArtifactFactory().createDependencyArtifact(groupId, artifactId, versionRange, type, classifier,
- scope, optional);
+ getArtifactFactory().createDependencyArtifact( groupId, artifactId, versionRange, type, classifier,
+ scope, optional );
- if (scope.equalsIgnoreCase(Artifact.SCOPE_SYSTEM)) {
- art.setFile(new File(dependency.getSystemPath()));
+ if ( scope.equalsIgnoreCase( Artifact.SCOPE_SYSTEM ) )
+ {
+ art.setFile( new File( dependency.getSystemPath() ) );
}
- handleExclusions(art, dependency);
+ handleExclusions( art, dependency );
- artifacts.add(art);
+ artifacts.add( art );
}
return artifacts;
@@ -761,7 +780,7 @@ public abstract class AbstractIdeSupport
/**
* Apply exclusion filters to direct AND transitive dependencies.
- *
+ *
* @param artifact
* @param dependency
*/
@@ -769,8 +788,9 @@ public abstract class AbstractIdeSupport
{
List exclusions = new ArrayList();
- for (Exclusion e : dependency.getExclusions()) {
- exclusions.add(e.getGroupId() + ":" + e.getArtifactId()); //$NON-NLS-1$
+ for ( Exclusion e : dependency.getExclusions() )
+ {
+ exclusions.add( e.getGroupId() + ":" + e.getArtifactId() ); //$NON-NLS-1$
}
ArtifactFilter newFilter = new ExcludesArtifactFilter( exclusions );
@@ -780,7 +800,7 @@ public abstract class AbstractIdeSupport
/**
* Utility method that locates a project producing the given artifact.
- *
+ *
* @param artifact the artifact a project should produce.
* @return <code>true</code> if the artifact is produced by a reactor projectart.
*/
@@ -791,7 +811,7 @@ public abstract class AbstractIdeSupport
/**
* Checks the list of reactor projects to see if the artifact is included.
- *
+ *
* @param artifact the artifact to check if it is in the reactor
* @return the reactor project or null if it is not in the reactor
*/
@@ -799,19 +819,22 @@ public abstract class AbstractIdeSupport
{
if ( reactorProjects != null )
{
- for (Object reactorProject1 : reactorProjects) {
+ for ( Object reactorProject1 : reactorProjects )
+ {
MavenProject reactorProject = (MavenProject) reactorProject1;
- if (reactorProject.getGroupId().equals(artifact.getGroupId())
- && reactorProject.getArtifactId().equals(artifact.getArtifactId())) {
- if (reactorProject.getVersion().equals(artifact.getVersion())) {
+ if ( reactorProject.getGroupId().equals( artifact.getGroupId() )
+ && reactorProject.getArtifactId().equals( artifact.getArtifactId() ) )
+ {
+ if ( reactorProject.getVersion().equals( artifact.getVersion() ) )
+ {
return reactorProject;
- } else {
- getLog().info(
- "Artifact "
- + artifact.getId()
- + " already available as a reactor project, but with different version. Expected: "
- + artifact.getVersion() + ", found: " + reactorProject.getVersion());
+ }
+ else
+ {
+ getLog().info( "Artifact " + artifact.getId()
+ + " already available as a reactor project, but with different version. Expected: "
+ + artifact.getVersion() + ", found: " + reactorProject.getVersion() );
}
}
}
@@ -835,23 +858,24 @@ public abstract class AbstractIdeSupport
if ( dependencyManagement != null && dependencyManagement.getDependencies() != null )
{
map = new HashMap();
- for (Dependency d : dependencyManagement.getDependencies()) {
- try {
- VersionRange versionRange = VersionRange.createFromVersionSpec(d.getVersion());
+ for ( Dependency d : dependencyManagement.getDependencies() )
+ {
+ try
+ {
+ VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
Artifact artifact =
- artifactFactory.createDependencyArtifact(d.getGroupId(), d.getArtifactId(), versionRange,
- d.getType(), d.getClassifier(), d.getScope(),
- d.isOptional());
-
- handleExclusions(artifact, d);
- map.put(d.getManagementKey(), artifact);
- } catch (InvalidVersionSpecificationException e) {
+ artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(), versionRange,
+ d.getType(), d.getClassifier(), d.getScope(),
+ d.isOptional() );
+
+ handleExclusions( artifact, d );
+ map.put( d.getManagementKey(), artifact );
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
throw new MojoExecutionException(
- Messages.getString(
- "AbstractIdeSupportMojo.unabletoparseversion", new Object[]{ //$NON-NLS-1$
- projectId, d.getVersion(),
- d.getManagementKey(), e.getMessage()}),
- e);
+ Messages.getString( "AbstractIdeSupportMojo.unabletoparseversion", new Object[]{ //$NON-NLS-1$
+ projectId, d.getVersion(), d.getManagementKey(), e.getMessage() } ), e );
}
}
}
@@ -867,7 +891,7 @@ public abstract class AbstractIdeSupport
* javadocs artifacts will be attached to the <code>IdeDependency</code> Resolve source and javadoc artifacts. The
* resolved artifacts will be downloaded based on the <code>downloadSources</code> and <code>downloadJavadocs</code>
* attributes. Source and
- *
+ *
* @param deps resolved dependencies
*/
private void resolveSourceAndJavadocArtifacts( IdeDependency[] deps )
@@ -882,9 +906,9 @@ public abstract class AbstractIdeSupport
/**
* Resolve the required artifacts for each of the dependency. <code>sources</code> or <code>javadoc</code> artifacts
* (depending on the <code>classifier</code>) are attached to the dependency.
- *
- * @param deps resolved dependencies
- * @param inClassifier the classifier we are looking for (either <code>sources</code> or <code>javadoc</code>)
+ *
+ * @param deps resolved dependencies
+ * @param inClassifier the classifier we are looking for (either <code>sources</code> or <code>javadoc</code>)
* @param includeRemoteRepositories flag whether we should search remote repositories for the artifacts or not
* @return the list of dependencies for which the required artifact was not found
*/
@@ -897,70 +921,84 @@ public abstract class AbstractIdeSupport
// local repository for reporting missing source jars
List remoteRepos = includeRemoteRepositories ? getRemoteArtifactRepositories() : Collections.EMPTY_LIST;
- for (IdeDependency dependency : deps) {
- if (dependency.isReferencedProject() || dependency.isSystemScoped()) {
+ for ( IdeDependency dependency : deps )
+ {
+ if ( dependency.isReferencedProject() || dependency.isSystemScoped() )
+ {
// artifact not needed
continue;
}
- if (getLog().isDebugEnabled()) {
+ if ( getLog().isDebugEnabled() )
+ {
getLog().debug(
- "Searching for sources for " + dependency.getId() + ":" + dependency.getClassifier()
- + " at " + dependency.getId() + ":" + inClassifier);
+ "Searching for sources for " + dependency.getId() + ":" + dependency.getClassifier() + " at "
+ + dependency.getId() + ":" + inClassifier );
}
Artifact baseArtifact =
- artifactFactory.createArtifactWithClassifier(dependency.getGroupId(), dependency.getArtifactId(),
- dependency.getVersion(), dependency.getType(),
- dependency.getClassifier());
+ artifactFactory.createArtifactWithClassifier( dependency.getGroupId(), dependency.getArtifactId(),
+ dependency.getVersion(), dependency.getType(),
+ dependency.getClassifier() );
baseArtifact =
- IdeUtils.resolveArtifact(artifactResolver, baseArtifact, remoteRepos, localRepository, getLog());
- if (!baseArtifact.isResolved()) {
+ IdeUtils.resolveArtifact( artifactResolver, baseArtifact, remoteRepos, localRepository, getLog() );
+ if ( !baseArtifact.isResolved() )
+ {
// base artifact does not exist - no point checking for javadoc/sources
continue;
}
Artifact artifact =
- IdeUtils.createArtifactWithClassifier(dependency.getGroupId(), dependency.getArtifactId(),
- dependency.getVersion(), dependency.getClassifier(),
- inClassifier, artifactFactory);
- File notAvailableMarkerFile = IdeUtils.getNotAvailableMarkerFile(localRepository, artifact);
-
- if (forceRecheck && notAvailableMarkerFile.exists()) {
- if (!notAvailableMarkerFile.delete()) {
- getLog().warn(
- Messages.getString("AbstractIdeSupportMojo.unabletodeletenotavailablemarkerfile",
- notAvailableMarkerFile));
+ IdeUtils.createArtifactWithClassifier( dependency.getGroupId(), dependency.getArtifactId(),
+ dependency.getVersion(), dependency.getClassifier(),
+ inClassifier, artifactFactory );
+ File notAvailableMarkerFile = IdeUtils.getNotAvailableMarkerFile( localRepository, artifact );
+
+ if ( forceRecheck && notAvailableMarkerFile.exists() )
+ {
+ if ( !notAvailableMarkerFile.delete() )
+ {
+ getLog().warn( Messages.getString( "AbstractIdeSupportMojo.unabletodeletenotavailablemarkerfile",
+ notAvailableMarkerFile ) );
}
}
- if (!notAvailableMarkerFile.exists()) {
+ if ( !notAvailableMarkerFile.exists() )
+ {
artifact =
- IdeUtils.resolveArtifact(artifactResolver, artifact, remoteRepos, localRepository, getLog());
- if (artifact.isResolved()) {
- if ("sources".equals(inClassifier)) {
- dependency.setSourceAttachment(artifact.getFile());
- } else if ("javadoc".equals(inClassifier)) {
- dependency.setJavadocAttachment(artifact.getFile());
+ IdeUtils.resolveArtifact( artifactResolver, artifact, remoteRepos, localRepository, getLog() );
+ if ( artifact.isResolved() )
+ {
+ if ( "sources".equals( inClassifier ) )
+ {
+ dependency.setSourceAttachment( artifact.getFile() );
+ }
+ else if ( "javadoc".equals( inClassifier ) )
+ {
+ dependency.setJavadocAttachment( artifact.getFile() );
}
- } else {
- if (includeRemoteRepositories) {
- try {
+ }
+ else
+ {
+ if ( includeRemoteRepositories )
+ {
+ try
+ {
notAvailableMarkerFile.createNewFile();
- getLog().debug(
- Messages.getString("AbstractIdeSupportMojo.creatednotavailablemarkerfile",
- notAvailableMarkerFile));
- } catch (IOException e) {
+ getLog().debug( Messages.getString( "AbstractIdeSupportMojo.creatednotavailablemarkerfile",
+ notAvailableMarkerFile ) );
+ }
+ catch ( IOException e )
+ {
getLog().warn(
- Messages.getString(
- "AbstractIdeSupportMojo.failedtocreatenotavailablemarkerfile",
- notAvailableMarkerFile));
+ Messages.getString( "AbstractIdeSupportMojo.failedtocreatenotavailablemarkerfile",
+ notAvailableMarkerFile ) );
}
}
// add the dependencies to the list
// of those lacking the required
// artifact
- missingClassifierDependencies.add(dependency);
+ missingClassifierDependencies.add( dependency );
}
}
}
@@ -982,9 +1020,11 @@ public abstract class AbstractIdeSupport
{
msg.append( Messages.getString( "AbstractIdeSupportMojo.sourcesnotavailable" ) ); //$NON-NLS-1$
- for (Object missingSourceDependency : missingSourceDependencies) {
+ for ( Object missingSourceDependency : missingSourceDependencies )
+ {
IdeDependency art = (IdeDependency) missingSourceDependency;
- msg.append(Messages.getString("AbstractIdeSupportMojo.sourcesmissingitem", art.getId())); //$NON-NLS-1$
+ msg.append(
+ Messages.getString( "AbstractIdeSupportMojo.sourcesmissingitem", art.getId() ) ); //$NON-NLS-1$
}
msg.append( "\n" ); //$NON-NLS-1$
}
@@ -993,9 +1033,11 @@ public abstract class AbstractIdeSupport
{
msg.append( Messages.getString( "AbstractIdeSupportMojo.javadocnotavailable" ) ); //$NON-NLS-1$
- for (Object missingJavadocDependency : missingJavadocDependencies) {
+ for ( Object missingJavadocDependency : missingJavadocDependencies )
+ {
IdeDependency art = (IdeDependency) missingJavadocDependency;
- msg.append(Messages.getString("AbstractIdeSupportMojo.javadocmissingitem", art.getId())); //$NON-NLS-1$
+ msg.append(
+ Messages.getString( "AbstractIdeSupportMojo.javadocmissingitem", art.getId() ) ); //$NON-NLS-1$
}
msg.append( "\n" ); //$NON-NLS-1$
}
@@ -1010,7 +1052,7 @@ public abstract class AbstractIdeSupport
/**
* Checks if jar has to be resolved for the given artifact
- *
+ *
* @param art the artifact to check
* @return true if resolution should happen
*/
@@ -1021,7 +1063,7 @@ public abstract class AbstractIdeSupport
/**
* Checks if a projects reference has to be used for the given artifact
- *
+ *
* @param art the artifact to check
* @return true if a project reference has to be used.
*/
@@ -1032,7 +1074,7 @@ public abstract class AbstractIdeSupport
/**
* Checks whether the currently running Maven satisfies the specified version (range).
- *
+ *
* @param version The version range to test for, must not be <code>null</code>.
* @return <code>true</code> if the current Maven version matches the specified version range, <code>false</code>
* otherwise.