Index: org.apache.ivyde.eclipse/.project
===================================================================
--- org.apache.ivyde.eclipse/.project (revision 905041)
+++ org.apache.ivyde.eclipse/.project (working copy)
@@ -1,52 +1,28 @@
-
-
-
- org.apache.ivyde.eclipse
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
- com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
- com.atlassw.tools.eclipse.checkstyle.CheckstyleNature
-
-
+
+
+ org.apache.ivyde.eclipse
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java
===================================================================
--- org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java (revision 905041)
+++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java (working copy)
@@ -329,6 +329,22 @@
return resolveBeforeLaunch;
}
+ public Boolean isInheritedMapIfOnlyOneSource() {
+ if (!isAdvancedProjectSpecific) {
+ return IvyPlugin.getPreferenceStoreHelper().getContainerMappingSetup()
+ .isMapIfOnlyOneSource();
+ }
+ return containerMappingSetup.isMapIfOnlyOneSource();
+ }
+
+ public Boolean isInheritedMapIfOnlyOneJavadoc() {
+ if (!isAdvancedProjectSpecific) {
+ return IvyPlugin.getPreferenceStoreHelper().getContainerMappingSetup()
+ .isMapIfOnlyOneJavadoc();
+ }
+ return containerMappingSetup.isMapIfOnlyOneJavadoc();
+ }
+
public String toString() {
return ivyXmlPath
+ (javaProject == null ? "" : " in '" + javaProject.getProject().getName() + "'");
Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ContainerMappingSetup.java
===================================================================
--- org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ContainerMappingSetup.java (revision 905041)
+++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/ContainerMappingSetup.java (working copy)
@@ -31,6 +31,10 @@
private List/* */javadocSuffixes;
+ private Boolean mapIfOnlyOneSource;
+
+ private Boolean mapIfOnlyOneJavadoc;
+
/**
* Default constructor
*/
@@ -44,6 +48,8 @@
this.javadocTypes = setup.javadocTypes;
this.sourceSuffixes = setup.sourceSuffixes;
this.javadocSuffixes = setup.javadocSuffixes;
+ this.mapIfOnlyOneSource = setup.mapIfOnlyOneSource;
+ this.mapIfOnlyOneJavadoc = setup.mapIfOnlyOneJavadoc;
}
public List getAcceptedTypes() {
@@ -86,4 +92,20 @@
this.javadocSuffixes = javadocSuffixes;
}
+ public Boolean isMapIfOnlyOneSource() {
+ return mapIfOnlyOneSource;
+ }
+
+ public void setMapIfOnlyOneSource(boolean autoMap) {
+ mapIfOnlyOneSource = Boolean.valueOf(autoMap);
+ }
+
+ public Boolean isMapIfOnlyOneJavadoc() {
+ return mapIfOnlyOneJavadoc;
+ }
+
+ public void setMapIfOnlyOneJavadoc(boolean autoMap) {
+ mapIfOnlyOneJavadoc = Boolean.valueOf(autoMap);
+ }
+
}
Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java
===================================================================
--- org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java (revision 905041)
+++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerMapper.java (working copy)
@@ -28,6 +28,8 @@
import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ArtifactDownloadReport;
import org.apache.ivy.core.resolve.DownloadOptions;
@@ -107,20 +109,39 @@
// let's look in the module declaring the artifact
ModuleRevisionId mrid = artifact.getId().getModuleRevisionId();
Artifact[] artifacts = (Artifact[]) artifactsByDependency.get(mrid);
+ Artifact sourceArtifact = null;
+ int nSourceArtifact = 0;
if (artifacts != null) {
for (int i = 0; i < artifacts.length; i++) {
Artifact metaArtifact = artifacts[i];
- if (isSourceArtifactName(artifact.getName(), metaArtifact.getName())
- && isSources(metaArtifact)) {
- // we've found the source artifact, let's provision it
- ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(metaArtifact,
- new DownloadOptions());
- if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists()) {
- return new Path(metaAdr.getLocalFile().getAbsolutePath());
+ if(isSources(metaArtifact)){
+ if (isSourceArtifactName(artifact.getName(), metaArtifact.getName())) {
+ // we've found the source artifact, let's provision it
+ ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(metaArtifact,
+ new DownloadOptions());
+ if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists()) {
+ return new Path(metaAdr.getLocalFile().getAbsolutePath());
+ }
}
+ // Last method to find source is based on : "If there is only one source artifact in the module, this is it !"
+ // So save the number of source artifacts and save the artifact (it may be the good one :-))
+ nSourceArtifact++;
+ sourceArtifact = metaArtifact;
}
}
}
+ if(conf.isInheritedMapIfOnlyOneSource().booleanValue()){
+ // we haven't found source artifact in the module declaring the artifact and having same name.
+ if(nSourceArtifact==1){
+ // If there is only 1 source artifact, it is the winner ;-)
+ ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(sourceArtifact,
+ new DownloadOptions());
+ if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists()) {
+ return new Path(metaAdr.getLocalFile().getAbsolutePath());
+ }
+ }
+ }
+ System.out.println("Sources artifact not found for : " + adr.getArtifact().toString());
return null;
}
@@ -142,20 +163,39 @@
// let's look in the module declaring the artifact
ModuleRevisionId mrid = artifact.getId().getModuleRevisionId();
Artifact[] artifacts = (Artifact[]) artifactsByDependency.get(mrid);
+ Artifact javadocArtifact = null;
+ int nJavadocArtifact = 0;
if (artifacts != null) {
for (int i = 0; i < artifacts.length; i++) {
Artifact metaArtifact = artifacts[i];
- if (isJavadocArtifactName(artifact.getName(), metaArtifact.getName())
- && isJavadoc(metaArtifact)) {
- // we've found the javadoc artifact, let's provision it
- ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(metaArtifact,
- new DownloadOptions());
- if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists()) {
- return new Path(metaAdr.getLocalFile().getAbsolutePath());
+ if(isJavadoc(metaArtifact)){
+ if (isJavadocArtifactName(artifact.getName(), metaArtifact.getName()) ) {
+ // we've found the javadoc artifact, let's provision it
+ ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(metaArtifact,
+ new DownloadOptions());
+ if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists()) {
+ return new Path(metaAdr.getLocalFile().getAbsolutePath());
+ }
}
+ // Last method to find javadoc is based on : "If there is only one javadoc artifact in the module, this is it !"
+ // So save the number of javadoc artifact and save the artifact (it may be the good one :-))
+ nJavadocArtifact++;
+ javadocArtifact = metaArtifact;
}
}
}
+ if(conf.isInheritedMapIfOnlyOneJavadoc().booleanValue()){
+ // we haven't found javadoc artifact in the module declaring the artifact and having same name.
+ if(nJavadocArtifact==1){
+ // If there is only 1 javadoc artifact, it is the winner ;-)
+ ArtifactDownloadReport metaAdr = ivy.getResolveEngine().download(javadocArtifact,
+ new DownloadOptions());
+ if (metaAdr.getLocalFile() != null && metaAdr.getLocalFile().exists()) {
+ return new Path(metaAdr.getLocalFile().getAbsolutePath());
+ }
+ }
+ }
+ System.out.println("Javadoc artifact not found for : " + adr.getArtifact().toString());
return null;
}
Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java
===================================================================
--- org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java (revision 905041)
+++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java (working copy)
@@ -167,6 +167,12 @@
} else if (parameter[0].equals("resolveBeforeLaunch")) {
conf.setResolveBeforeLaunch(Boolean.valueOf(value).booleanValue());
conf.setAdvancedProjectSpecific(true);
+ } else if (parameter[0].equals("mapIfOnlyOneSource")) {
+ mappingSetup.setMapIfOnlyOneSource(Boolean.valueOf(value).booleanValue());
+ conf.setAdvancedProjectSpecific(true);
+ } else if (parameter[0].equals("mapIfOnlyOneJavadoc")) {
+ mappingSetup.setMapIfOnlyOneJavadoc(Boolean.valueOf(value).booleanValue());
+ conf.setAdvancedProjectSpecific(true);
}
}
if (conf.isAdvancedProjectSpecific()) {
@@ -248,6 +254,12 @@
if (mappingSetup.getJavadocSuffixes() == null) {
mappingSetup.setJavadocSuffixes(prefStoreMappingSetup.getJavadocSuffixes());
}
+ if (mappingSetup.isMapIfOnlyOneSource() == null) {
+ mappingSetup.setMapIfOnlyOneSource(prefStoreMappingSetup.isMapIfOnlyOneSource().booleanValue());
+ }
+ if (mappingSetup.isMapIfOnlyOneJavadoc() == null) {
+ mappingSetup.setMapIfOnlyOneJavadoc(prefStoreMappingSetup.isMapIfOnlyOneJavadoc().booleanValue());
+ }
}
public static IPath getPath(IvyClasspathContainerConfiguration conf) {
@@ -281,6 +293,8 @@
append(path, "alphaOrder", conf.isAlphaOrder());
append(path, "resolveInWorkspace", conf.isResolveInWorkspace());
append(path, "resolveBeforeLaunch", conf.isResolveBeforeLaunch());
+ append(path, "mapIfOnlyOneSource", setup.isMapIfOnlyOneSource().booleanValue());
+ append(path, "mapIfOnlyOneJavadoc", setup.isMapIfOnlyOneJavadoc().booleanValue());
}
} catch (UnsupportedEncodingException e) {
IvyPlugin.log(IStatus.ERROR, UTF8_ERROR, e);
Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java
===================================================================
--- org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java (revision 905041)
+++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceInitializer.java (working copy)
@@ -59,6 +59,10 @@
public static final String DEFAULT_JAVADOC_SUFFIXES = "-javadoc,-javadocs,-doc,-docs";
+ public static final boolean DEFAULT_MAP_IF_ONLY_ONE_SOURCE = false;
+
+ public static final boolean DEFAULT_MAP_IF_ONLY_ONE_JAVADOC= false;
+
public static final int DEFAULT_IVY_CONSOLE_LOG_MESSAGE = Message.MSG_INFO;
public static final ContainerMappingSetup DEFAULT_CONTAINER_MAPPING_SETUP =
@@ -75,6 +79,8 @@
.split(DEFAULT_SOURCES_SUFFIXES));
DEFAULT_CONTAINER_MAPPING_SETUP.setJavadocSuffixes(IvyClasspathUtil
.split(DEFAULT_JAVADOC_SUFFIXES));
+ DEFAULT_CONTAINER_MAPPING_SETUP.setMapIfOnlyOneSource(DEFAULT_MAP_IF_ONLY_ONE_SOURCE);
+ DEFAULT_CONTAINER_MAPPING_SETUP.setMapIfOnlyOneJavadoc(DEFAULT_MAP_IF_ONLY_ONE_JAVADOC);
}
public static final boolean DEFAULT_DO_RETRIEVE = false;
@@ -127,6 +133,8 @@
store.setDefault(PreferenceConstants.JAVADOC_TYPES, DEFAULT_JAVADOC_TYPES);
store.setDefault(PreferenceConstants.SOURCES_SUFFIXES, DEFAULT_SOURCES_SUFFIXES);
store.setDefault(PreferenceConstants.JAVADOC_SUFFIXES, DEFAULT_JAVADOC_SUFFIXES);
+ store.setDefault(PreferenceConstants.MAP_IF_ONLY_ONE_SOURCE, DEFAULT_MAP_IF_ONLY_ONE_SOURCE);
+ store.setDefault(PreferenceConstants.MAP_IF_ONLY_ONE_JAVADOC, DEFAULT_MAP_IF_ONLY_ONE_JAVADOC);
store.setDefault(PreferenceConstants.DO_RETRIEVE, DEFAULT_DO_RETRIEVE);
boolean b = store.getBoolean(PreferenceConstants.DO_RETRIEVE_DEPRECATED);
Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java
===================================================================
--- org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java (revision 905041)
+++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java (working copy)
@@ -84,4 +84,9 @@
public static final String IGNORE_VERSION_ON_WORKSPACE_PROJECTS
= "workspaceResolver.ignoreVersion";
+
+ public static final String MAP_IF_ONLY_ONE_SOURCE = "mapIfOnlyOneSource";
+
+ public static final String MAP_IF_ONLY_ONE_JAVADOC = "mapIfOnlyOneJavadoc";
+
}
Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java
===================================================================
--- org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java (revision 905041)
+++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java (working copy)
@@ -77,6 +77,8 @@
.getString(PreferenceConstants.SOURCES_SUFFIXES)));
setup.setJavadocSuffixes(IvyClasspathUtil.split(prefStore
.getString(PreferenceConstants.JAVADOC_SUFFIXES)));
+ setup.setMapIfOnlyOneSource(prefStore.getBoolean(PreferenceConstants.MAP_IF_ONLY_ONE_SOURCE));
+ setup.setMapIfOnlyOneJavadoc(prefStore.getBoolean(PreferenceConstants.MAP_IF_ONLY_ONE_JAVADOC));
return setup;
}
@@ -91,6 +93,8 @@
.getSourceSuffixes()));
prefStore.setValue(PreferenceConstants.JAVADOC_SUFFIXES, IvyClasspathUtil.concat(setup
.getJavadocSuffixes()));
+ prefStore.setValue(PreferenceConstants.MAP_IF_ONLY_ONE_SOURCE, setup.isMapIfOnlyOneSource().booleanValue());
+ prefStore.setValue(PreferenceConstants.MAP_IF_ONLY_ONE_JAVADOC, setup.isMapIfOnlyOneJavadoc().booleanValue());
}
public RetrieveSetup getRetrieveSetup() {
@@ -199,4 +203,5 @@
prefStore.setValue(PreferenceConstants.IGNORE_VERSION_ON_WORKSPACE_PROJECTS,
ignoreVersionOnWorkspaceProjects);
}
+
}
Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/AcceptedSuffixesTypesComposite.java
===================================================================
--- org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/AcceptedSuffixesTypesComposite.java (revision 905041)
+++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/AcceptedSuffixesTypesComposite.java (working copy)
@@ -22,6 +22,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -42,7 +43,15 @@
public static final String TOOLTIP_JAVADOC_SUFFIXES = "Comma separated list of suffixes to"
+ " match javadocs to artifacts.\nExample: -javadoc, -doc";
+
+ public static final String TOOLTIP_MAP_IF_ONLY_ONE_SOURCE = "Will map the source artifact"
+ + " to all jar artifact in modules with multiple jar artifacts and only one"
+ + " source artifact";
+ public static final String TOOLTIP_MAP_IF_ONLY_ONE_JAVADOC= "Will map the javadoc artifact"
+ + " to all jar artifact in modules with multiple jar artifacts and only one"
+ + " javadoc artifact";
+
private Text acceptedTypesText;
private Text sourceTypesText;
@@ -53,6 +62,10 @@
private Text javadocSuffixesText;
+ private Button mapIfOnlyOneSourceCheck;
+
+ private Button mapIfOnlyOneJavadocCheck;
+
public AcceptedSuffixesTypesComposite(Composite parent, int style) {
super(parent, style);
GridLayout layout = new GridLayout(2, false);
@@ -95,6 +108,19 @@
javadocSuffixesText = new Text(this, SWT.SINGLE | SWT.BORDER);
javadocSuffixesText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
javadocSuffixesText.setToolTipText(TOOLTIP_JAVADOC_SUFFIXES);
+
+ mapIfOnlyOneSourceCheck= new Button(this, SWT.CHECK);
+ mapIfOnlyOneSourceCheck.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
+ false, 2, 1));
+ mapIfOnlyOneSourceCheck.setText("Auto map jar artifacts with unique source artifact");
+ mapIfOnlyOneSourceCheck.setToolTipText(TOOLTIP_MAP_IF_ONLY_ONE_SOURCE);
+
+ mapIfOnlyOneJavadocCheck = new Button(this, SWT.CHECK);
+ mapIfOnlyOneJavadocCheck.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
+ false, 2, 1));
+ mapIfOnlyOneJavadocCheck.setText("Auto map jar artifacts with unique javadoc artifact");
+ mapIfOnlyOneJavadocCheck.setToolTipText(TOOLTIP_MAP_IF_ONLY_ONE_JAVADOC);
+
}
public void init(ContainerMappingSetup setup) {
@@ -103,6 +129,8 @@
sourceSuffixesText.setText(IvyClasspathUtil.concat(setup.getSourceSuffixes()));
javadocTypesText.setText(IvyClasspathUtil.concat(setup.getJavadocTypes()));
javadocSuffixesText.setText(IvyClasspathUtil.concat(setup.getJavadocSuffixes()));
+ mapIfOnlyOneSourceCheck.setSelection(setup.isMapIfOnlyOneSource().booleanValue());
+ mapIfOnlyOneJavadocCheck.setSelection(setup.isMapIfOnlyOneJavadoc().booleanValue());
}
public void setEnabled(boolean enabled) {
@@ -112,6 +140,8 @@
sourceSuffixesText.setEnabled(enabled);
javadocTypesText.setEnabled(enabled);
javadocSuffixesText.setEnabled(enabled);
+ mapIfOnlyOneSourceCheck.setEnabled(enabled);
+ mapIfOnlyOneJavadocCheck.setEnabled(enabled);
}
public ContainerMappingSetup getContainerMappingSetup() {
@@ -121,6 +151,8 @@
setup.setJavadocTypes(IvyClasspathUtil.split(javadocTypesText.getText()));
setup.setSourceSuffixes(IvyClasspathUtil.split(sourceSuffixesText.getText()));
setup.setJavadocSuffixes(IvyClasspathUtil.split(javadocSuffixesText.getText()));
+ setup.setMapIfOnlyOneSource(mapIfOnlyOneSourceCheck.getSelection());
+ setup.setMapIfOnlyOneJavadoc(mapIfOnlyOneJavadocCheck.getSelection());
return setup;
}
}