Here's a very ugly patch to fix this for the users who desparately need it.
This patch also fixes the global settings.xml file not used problem in MECLIPSE-2261 by specifying a hard coded global settings.xml file (change the global settings file to the path to your installation).
Regards,
Bulent Erdemir
Index: C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/src/org/maven/ide/eclipse/embedder/EmbedderFactory.java
===================================================================
— C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/src/org/maven/ide/eclipse/embedder/EmbedderFactory.java (revision 179)
+++ C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/src/org/maven/ide/eclipse/embedder/EmbedderFactory.java (working copy)
@@ -20,6 +20,8 @@
+import java.io.File;
+
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.embedder.ContainerCustomizer;
import org.apache.maven.embedder.DefaultMavenEmbedRequest;
@@ -40,6 +42,10 @@
MavenEmbedRequest request = new DefaultMavenEmbedRequest();
request.setConfigurationCustomizer(customizer);
+
+ File gsFile = new File("c:/dev/tools/maven/conf/settings.xml");
+ logger.info("Hoba.Loading global settings from " + gsFile.getAbsolutePath());
+ request.setGlobalSettingsFile(gsFile);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Index: C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/src/org/maven/ide/eclipse/embedder/ClassPathResolver.java
===================================================================
— C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/src/org/maven/ide/eclipse/embedder/ClassPathResolver.java (revision 179)
+++ C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/src/org/maven/ide/eclipse/embedder/ClassPathResolver.java (working copy)
@@ -145,8 +145,9 @@
Path srcPath = materializeArtifactPath(embedder, mavenProject, a, "java-source", "sources", downloadSources, monitor);
IClasspathAttribute[] attributes = new IClasspathAttribute[0];
- if(srcPath == null) { // no need to search for javadoc if we have source code
- Path javadocPath = materializeArtifactPath(embedder, mavenProject, a, "java-doc", "javadoc", downloadJavadoc, monitor);
+ //if(srcPath == null) { // no need to search for javadoc if we have source code
+ //Path javadocPath = materializeArtifactPath(embedder, mavenProject, a, "java-doc", "javadoc", downloadJavadoc, monitor);
+ Path javadocPath = materializeArtifactPathJavadoc(embedder, mavenProject, a, "javadoc", "javadoc", downloadJavadoc, monitor);
String javaDocUrl = null;
if(javadocPath != null)
Unknown macro: { javaDocUrl = Maven2ClasspathContainerInitializer.getJavaDocUrl(javadocPath.toString());@@ -157,7 +158,7 @@ attributes = new IClasspathAttribute[] {JavaCore.newClasspathAttribute(
IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, javaDocUrl)}; }
- }
+ //}
libraryEntries.add(JavaCore.newLibraryEntry(new Path(artifactLocation), srcPath, null, new IAccessRule[0],
attributes, false /not exported/));
@@ -233,7 +234,37 @@
}
return null;
}
+
+ // type = "javadoc"
+ private Path materializeArtifactPathJavadoc(MavenEmbedder embedder, MavenProject mavenProject, Artifact a, String type,
+ String suffix, boolean download, IProgressMonitor monitor) throws Exception {
+ String artifactLocation = a.getFile().getAbsolutePath();
+ // artifactLocation ends on '.jar' or '.zip'
+ //File file = new File(artifactLocation.substring(0, artifactLocation.length() - 4) + "-" + suffix + ".jar");
+ File file = new File(artifactLocation.substring(0, artifactLocation.length() - 4) + "-" + type + "." + suffix);
+ if(file.exists())
{
+ // XXX ugly hack to do not download any artifacts
+ return new Path(file.getAbsolutePath());
+ }
else if(download) {
+ monitor.beginTask("Resolve " + type + " " + a.getId(), IProgressMonitor.UNKNOWN);
+ try {
+ Artifact f = embedder.createArtifactWithClassifier(a.getGroupId(), a.getArtifactId(), a.getVersion(),
+ type, suffix);
+ if(f != null)
{
+ embedder.resolve(f, mavenProject.getRemoteArtifactRepositories(), embedder.getLocalRepository());
+ return new Path(f.getFile().getAbsolutePath());
+ }
+ } catch(AbstractArtifactResolutionException ex)
{
+ String name = ex.getGroupId() + ":" + ex.getArtifactId() + "-" + ex.getVersion() + "." + ex.getType();
+ console.logError(ex.getOriginalMessage() + " " + name);
+ }
finally
{
+ monitor.done();
+ }
+ }
+ return null;
+ }
+
private String getJavaDocUrl(String artifactLocation, IProgressMonitor monitor) throws CoreException {
// guess the javadoc url from the project url in the artifact's pom.xml
File file = new File(artifactLocation.substring(0, artifactLocation.length()-4) + ".pom");
@@ -278,6 +309,7 @@
request.setPomFile(pomFile.getAbsolutePath());
request.setBaseDirectory(pomFile.getParentFile());
request.setTransferListener(new TransferListenerAdapter(monitor, console, indexManager));
+ request.setSettingsFile("c:/dev/tools/maven/conf/settings.xml");
MavenExecutionResult result = mavenEmbedder.readProjectWithDependencies(request);
Index: C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/META-INF/MANIFEST.MF
===================================================================
— C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/META-INF/MANIFEST.MF (revision 179)
+++ C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/META-INF/MANIFEST.MF (working copy)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: Maven 2.0 integration
Bundle-SymbolicName: org.maven.ide.eclipse; singleton:=true
-Bundle-Version: 0.0.10
+Bundle-Version: 0.0.10.1
Bundle-Activator: org.maven.ide.eclipse.Maven2Plugin
Bundle-Vendor: maven.org
Bundle-Localization: plugin
Here's a very ugly patch to fix this for the users who desparately need it.
This patch also fixes the global settings.xml file not used problem in MECLIPSE-2261 by specifying a hard coded global settings.xml file (change the global settings file to the path to your installation).
Regards,
Bulent Erdemir
Index: C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/src/org/maven/ide/eclipse/embedder/EmbedderFactory.java
===================================================================
— C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/src/org/maven/ide/eclipse/embedder/EmbedderFactory.java (revision 179)
+++ C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/src/org/maven/ide/eclipse/embedder/EmbedderFactory.java (working copy)
@@ -20,6 +20,8 @@
*/
+import java.io.File;
+
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.embedder.ContainerCustomizer;
import org.apache.maven.embedder.DefaultMavenEmbedRequest;
@@ -40,6 +42,10 @@
MavenEmbedRequest request = new DefaultMavenEmbedRequest();
request.setConfigurationCustomizer(customizer);
+
+ File gsFile = new File("c:/dev/tools/maven/conf/settings.xml");
+ logger.info("Hoba.Loading global settings from " + gsFile.getAbsolutePath());
+ request.setGlobalSettingsFile(gsFile);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Index: C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/src/org/maven/ide/eclipse/embedder/ClassPathResolver.java
===================================================================
— C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/src/org/maven/ide/eclipse/embedder/ClassPathResolver.java (revision 179)
+++ C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/src/org/maven/ide/eclipse/embedder/ClassPathResolver.java (working copy)
@@ -145,8 +145,9 @@
Path srcPath = materializeArtifactPath(embedder, mavenProject, a, "java-source", "sources", downloadSources, monitor);
IClasspathAttribute[] attributes = new IClasspathAttribute[0];
+ //if(srcPath == null) { // no need to search for javadoc if we have source code
+ //Path javadocPath = materializeArtifactPath(embedder, mavenProject, a, "java-doc", "javadoc", downloadJavadoc, monitor);
+ Path javadocPath = materializeArtifactPathJavadoc(embedder, mavenProject, a, "javadoc", "javadoc", downloadJavadoc, monitor);
String javaDocUrl = null;
if(javadocPath != null)
+ //}
libraryEntries.add(JavaCore.newLibraryEntry(new Path(artifactLocation), srcPath, null, new IAccessRule[0],
{ + // XXX ugly hack to do not download any artifacts + return new Path(file.getAbsolutePath()); + }attributes, false /not exported/));
@@ -233,7 +234,37 @@
}
return null;
}
+
+ // type = "javadoc"
+ private Path materializeArtifactPathJavadoc(MavenEmbedder embedder, MavenProject mavenProject, Artifact a, String type,
+ String suffix, boolean download, IProgressMonitor monitor) throws Exception {
+ String artifactLocation = a.getFile().getAbsolutePath();
+ // artifactLocation ends on '.jar' or '.zip'
+ //File file = new File(artifactLocation.substring(0, artifactLocation.length() - 4) + "-" + suffix + ".jar");
+ File file = new File(artifactLocation.substring(0, artifactLocation.length() - 4) + "-" + type + "." + suffix);
+ if(file.exists())
else if(download) {
{ + embedder.resolve(f, mavenProject.getRemoteArtifactRepositories(), embedder.getLocalRepository()); + return new Path(f.getFile().getAbsolutePath()); + }+ monitor.beginTask("Resolve " + type + " " + a.getId(), IProgressMonitor.UNKNOWN);
+ try {
+ Artifact f = embedder.createArtifactWithClassifier(a.getGroupId(), a.getArtifactId(), a.getVersion(),
+ type, suffix);
+ if(f != null)
+ } catch(AbstractArtifactResolutionException ex)
{ + String name = ex.getGroupId() + ":" + ex.getArtifactId() + "-" + ex.getVersion() + "." + ex.getType(); + console.logError(ex.getOriginalMessage() + " " + name); + }finally
{ + monitor.done(); + }+ }
+ return null;
+ }
+
private String getJavaDocUrl(String artifactLocation, IProgressMonitor monitor) throws CoreException {
// guess the javadoc url from the project url in the artifact's pom.xml
File file = new File(artifactLocation.substring(0, artifactLocation.length()-4) + ".pom");
@@ -278,6 +309,7 @@
request.setPomFile(pomFile.getAbsolutePath());
request.setBaseDirectory(pomFile.getParentFile());
request.setTransferListener(new TransferListenerAdapter(monitor, console, indexManager));
+ request.setSettingsFile("c:/dev/tools/maven/conf/settings.xml");
MavenExecutionResult result = mavenEmbedder.readProjectWithDependencies(request);
Index: C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/META-INF/MANIFEST.MF
===================================================================
— C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/META-INF/MANIFEST.MF (revision 179)
+++ C:/dev/projects/maven/m2eclipse/org.maven.ide.eclipse/META-INF/MANIFEST.MF (working copy)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: Maven 2.0 integration
Bundle-SymbolicName: org.maven.ide.eclipse; singleton:=true
-Bundle-Version: 0.0.10
+Bundle-Version: 0.0.10.1
Bundle-Activator: org.maven.ide.eclipse.Maven2Plugin
Bundle-Vendor: maven.org
Bundle-Localization: plugin