### Eclipse Workspace Patch 1.0 #P ivyde 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 729353) +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfiguration.java (working copy) @@ -18,6 +18,7 @@ package org.apache.ivyde.eclipse.cpcontainer; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; @@ -25,9 +26,12 @@ import java.net.URLDecoder; import java.net.URLEncoder; import java.text.ParseException; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Iterator; import java.util.List; +import java.util.Properties; import org.apache.ivy.Ivy; import org.apache.ivy.core.module.descriptor.ModuleDescriptor; @@ -38,6 +42,7 @@ import org.apache.ivyde.eclipse.IvyPlugin; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -72,6 +77,8 @@ List/* */confs = Arrays.asList(new String[] {"*"}); String ivySettingsPath; + + List/* */buildPropertyFiles; List/* */acceptedTypes; @@ -238,6 +245,9 @@ } else if (parameter[0].equals("resolveInWorkspace")) { resolveInWorkspace = Boolean.valueOf(value).booleanValue(); isAdvancedProjectSpecific = true; + } else if (parameter[0].equals("buildPropertyFiles")) { + buildPropertyFiles = IvyClasspathUtil.split(value); + isAdvancedProjectSpecific = true; } } if (isAdvancedProjectSpecific) { @@ -282,6 +292,9 @@ if (acceptedTypes == null) { acceptedTypes = IvyPlugin.getPreferenceStoreHelper().getAcceptedTypes(); } + if (buildPropertyFiles == null) { + buildPropertyFiles = IvyPlugin.getPreferenceStoreHelper().getBuildPropertyFiles(); + } if (sourceTypes == null) { sourceTypes = IvyPlugin.getPreferenceStoreHelper().getSourceTypes(); } @@ -335,6 +348,9 @@ path.append(URLEncoder.encode(Boolean.toString(alphaOrder), "UTF-8")); path.append("&resolveInWorkspace="); path.append(URLEncoder.encode(Boolean.toString(this.resolveInWorkspace), "UTF-8")); + path.append("&buildPropertyFiles="); + path.append(URLEncoder.encode(IvyClasspathUtil.concat(buildPropertyFiles), "UTF-8")); + } } catch (UnsupportedEncodingException e) { IvyPlugin.log(IStatus.ERROR, UTF8_ERROR, e); @@ -430,6 +446,7 @@ ivy = Ivy.newInstance(ivySettings); } setConfStatus(null); + configureIvyProperties(ivy, getInheritedBuildPropertyFiles()); return ivy; } @@ -511,6 +528,7 @@ } } setConfStatus(null); + configureIvyProperties(ivy, getInheritedBuildPropertyFiles()); return ivy; } @@ -551,7 +569,7 @@ ivy = Ivy.newInstance(ivySettings); ivySettingsLastModified = file.lastModified(); } - + configureIvyProperties(ivy, getInheritedBuildPropertyFiles()); return ivy; } @@ -706,5 +724,58 @@ throw ex; } } + + private static void configureIvyProperties(Ivy ivy, Collection buildPropertyFiles) { + if (buildPropertyFiles != null) { + Iterator iter = buildPropertyFiles.iterator(); + while (iter.hasNext()) { + try { + String file = (String)iter.next(); + Properties props = new Properties(); + FileInputStream fis = new FileInputStream(new File(new URL(file).getPath())); + props.load(fis); + fis.close(); + + Iterator keys = props.keySet().iterator(); + while (keys.hasNext()) { + String key = (String)keys.next(); + String value = props.getProperty(key); + ivy.getSettings().setVariable(key, value); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + private Collection getUnresolvedInheritedBuildPropertyFiles() { + if (!isAdvancedProjectSpecific) { + return IvyPlugin.getPreferenceStoreHelper().getBuildPropertyFiles(); + } else { + return buildPropertyFiles; + } + } + + + public Collection getInheritedBuildPropertyFiles() { + Collection files = getUnresolvedInheritedBuildPropertyFiles(); + ArrayList list = new ArrayList(); + if (files != null) { + Iterator iter = files.iterator(); + while (iter.hasNext()) { + try { + String file = (String)iter.next(); + IProject project = javaProject.getProject(); + File loc = project.getLocation().toFile(); + File buildFile = new File(loc, file); + list.add(buildFile.toURL().toString()); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return list; + } } Index: org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java =================================================================== --- org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java (revision 729353) +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvydeContainerPage.java (working copy) @@ -50,6 +50,7 @@ import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; +import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.PreferencesUtil; public class IvydeContainerPage extends NewElementWizardPage implements IClasspathContainerPage, @@ -89,6 +90,8 @@ private Link retrieveGeneralSettingsLink; + private Text buildPropertiesText; + /** * Constructor */ @@ -149,6 +152,7 @@ } if (advancedProjectSpecificButton.getSelection()) { conf.isAdvancedProjectSpecific = true; + conf.buildPropertyFiles = IvyClasspathUtil.split(buildPropertiesText.getText()); conf.acceptedTypes = acceptedSuffixesTypesComposite.getAcceptedTypes(); conf.sourceTypes = acceptedSuffixesTypesComposite.getSourcesTypes(); conf.javadocTypes = acceptedSuffixesTypesComposite.getJavadocTypes(); @@ -399,6 +403,16 @@ alphaOrderCheck.add("From the ivy.xml"); alphaOrderCheck.add("Lexical"); + label = new Label(configComposite, SWT.NONE); + label.setText("Build Property Files:"); + + buildPropertiesText = new Text(configComposite, SWT.SINGLE | SWT.BORDER); + buildPropertiesText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, + 1)); + buildPropertiesText + .setToolTipText("Comma separated list of build property files.\nExample: build.properties, override.properties"); + + acceptedSuffixesTypesComposite = new AcceptedSuffixesTypesComposite(configComposite, SWT.NONE); acceptedSuffixesTypesComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, @@ -448,12 +462,14 @@ conf.sourceSuffixes, conf.javadocTypes, conf.javadocSuffixes); alphaOrderCheck.select(conf.alphaOrder ? 1 : 0); resolveInWorkspaceCheck.setSelection(this.conf.resolveInWorkspace); + buildPropertiesText.setText(IvyClasspathUtil.concat(conf.buildPropertyFiles)); } else { advancedProjectSpecificButton.setSelection(false); acceptedSuffixesTypesComposite.init(helper.getAcceptedTypes(), helper.getSourceTypes(), helper.getSourceSuffixes(), helper.getJavadocTypes(), helper.getJavadocSuffixes()); alphaOrderCheck.select(helper.isAlphOrder() ? 1 : 0); resolveInWorkspaceCheck.setSelection(helper.isResolveInWorkspace()); + buildPropertiesText.setText(IvyClasspathUtil.concat(helper.getBuildPropertyFiles())); } updateFieldsStatusSettings(); @@ -479,6 +495,7 @@ acceptedSuffixesTypesComposite.setEnabled(projectSpecific); alphaOrderCheck.setEnabled(projectSpecific); resolveInWorkspaceCheck.setEnabled(projectSpecific); + buildPropertiesText.setEnabled(projectSpecific); } public void initialize(IJavaProject p, IClasspathEntry[] currentEntries) { 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 729353) +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/IvyDEPreferenceStoreHelper.java (working copy) @@ -54,6 +54,8 @@ public static final boolean DEFAULT_ALPHABETICAL_ORDER = false; public static final boolean DEFAULT_RESOLVE_IN_WORKSPACE = false; + + public static final String DEFAULT_BUILD_PROPERTY_FILES = ""; private final IPreferenceStore prefStore; @@ -96,6 +98,7 @@ prefStore.setDefault(PreferenceConstants.ALPHABETICAL_ORDER, DEFAULT_ALPHABETICAL_ORDER); prefStore .setDefault(PreferenceConstants.RESOLVE_IN_WORKSPACE, DEFAULT_RESOLVE_IN_WORKSPACE); + prefStore.setDefault(PreferenceConstants.BUILD_PROPERTY_FILES, DEFAULT_BUILD_PROPERTY_FILES); } public String getIvyOrg() { @@ -234,4 +237,7 @@ prefStore.setValue(PreferenceConstants.ORGANISATION_URL, url); } + public List getBuildPropertyFiles() { + return IvyClasspathUtil.split(prefStore.getString(PreferenceConstants.BUILD_PROPERTY_FILES)); + } } 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 729353) +++ org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/preferences/PreferenceConstants.java (working copy) @@ -66,5 +66,6 @@ public static final String RESOLVE_IN_WORKSPACE = "resolveInWorkspace"; + public static final String BUILD_PROPERTY_FILES = "buildPropertyFiles"; }