Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2009-04-23 14:33:44 -0400
committerPascal Rapicault2009-04-23 14:33:44 -0400
commit9fcfced640aa4e4e24f51c88aadd2d6787a07c13 (patch)
tree81cc2fe29b3a4504e616b695f32e963bd3bd27ef /bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse
parentf4183426a566f3c3d9be31c08bd60e4ebf660f1a (diff)
downloadrt.equinox.p2-9fcfced640aa4e4e24f51c88aadd2d6787a07c13.tar.gz
rt.equinox.p2-9fcfced640aa4e4e24f51c88aadd2d6787a07c13.tar.xz
rt.equinox.p2-9fcfced640aa4e4e24f51c88aadd2d6787a07c13.zip
Bug 265550 - Review Ant task consistency
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse')
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java141
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ComparatorDescription.java54
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CompositeRepositoryTask.java65
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/DestinationRepository.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java75
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryFileSet.java67
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryList.java42
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SlicingOption.java4
10 files changed, 393 insertions, 73 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java
index 149cb7a56..59f8a2f46 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java
@@ -16,12 +16,14 @@ import java.net.URISyntaxException;
import java.util.*;
import org.apache.tools.ant.*;
import org.apache.tools.ant.types.FileSet;
-import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.equinox.internal.p2.artifact.repository.ant.AntMirrorLog;
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.internal.provisional.p2.query.Collector;
import org.eclipse.equinox.internal.provisional.p2.query.Query;
-import org.eclipse.equinox.p2.internal.repository.tools.AbstractApplication;
+import org.eclipse.equinox.p2.internal.repository.tools.*;
+import org.eclipse.osgi.util.NLS;
public abstract class AbstractRepositoryTask extends Task {
protected static final String ANT_PREFIX = "${"; //$NON-NLS-1$
@@ -30,21 +32,18 @@ public abstract class AbstractRepositoryTask extends Task {
protected List sourceRepos = new ArrayList();
protected List destinations = new ArrayList();
- /*
- * Create a special file set since the user specified a "source" sub-element.
- */
- public FileSet createSource() {
- MyFileSet set = new MyFileSet();
- sourceRepos.add(set);
- return set;
- }
-
protected void addMetadataSourceRepository(URI repoLocation) {
- application.addSourceMetadataRepository(repoLocation);
+ RepositoryDescriptor source = new RepositoryDescriptor();
+ source.setLocation(repoLocation);
+ source.setKind(RepositoryDescriptor.KIND_METADATA);
+ application.addSource(source);
}
protected void addArtifactSourceRepository(URI repoLocation) {
- application.addSourceArtifactRepository(repoLocation);
+ RepositoryDescriptor source = new RepositoryDescriptor();
+ source.setLocation(repoLocation);
+ source.setKind(RepositoryDescriptor.KIND_ARTIFACT);
+ application.addSource(source);
}
/*
@@ -61,8 +60,13 @@ public abstract class AbstractRepositoryTask extends Task {
* argument to specify both the artifact and metadata repositories.
*/
public void setSource(String location) {
- application.addSourceArtifactRepository(location);
- application.addSourceMetadataRepository(location);
+ RepositoryDescriptor source = new RepositoryDescriptor();
+ try {
+ source.setLocation(URIUtil.fromString(location));
+ application.addSource(source);
+ } catch (URISyntaxException e) {
+ throw new BuildException(e);
+ }
}
/*
@@ -70,20 +74,15 @@ public abstract class AbstractRepositoryTask extends Task {
* argument to specify both the artifact and metadata repositories.
*/
public void setDestination(String location) {
- DestinationRepository metadata = new DestinationRepository();
- metadata.setLocation(URIUtil.toUnencodedString(new Path(location).toFile().toURI()));
- metadata.setKind("metadata"); //$NON-NLS-1$
- application.addDestination(metadata.getDescriptor());
- destinations.add(metadata);
-
- DestinationRepository artifact = new DestinationRepository();
- artifact.setLocation(URIUtil.toUnencodedString(new Path(location).toFile().toURI()));
- metadata.setKind("artifact"); //$NON-NLS-1$
- application.addDestination(artifact.getDescriptor());
- destinations.add(artifact);
+ // TODO depreciate
+ DestinationRepository dest = new DestinationRepository();
+ dest.setLocation(location);
+ destinations.add(dest);
+ application.addDestination(dest.getDescriptor());
}
public DestinationRepository createDestination() {
+ // TODO depreciate
DestinationRepository destination = new DestinationRepository();
destinations.add(destination);
application.addDestination(destination.getDescriptor());
@@ -91,17 +90,28 @@ public abstract class AbstractRepositoryTask extends Task {
}
/*
- * New FileSet subclass which adds an optional "location" attribute.
+ * Add a repository to mirror into
*/
- public class MyFileSet extends FileSet {
- String location;
+ public DestinationRepository createRepository() {
+ DestinationRepository destination = new DestinationRepository();
+ destinations.add(destination);
+ application.addDestination(destination.getDescriptor());
+ return destination;
+ }
- public MyFileSet() {
- super();
+ /*
+ * Add source repositories to mirror from
+ */
+ public void addConfiguredSource(RepositoryList sourceList) {
+ for (Iterator iter = sourceList.getRepositoryList().iterator(); iter.hasNext();) {
+ DestinationRepository repo = (DestinationRepository) iter.next();
+ application.addSource(repo.getDescriptor());
}
- public void setLocation(String value) {
- this.location = value;
+ for (Iterator iter = sourceList.getFileSetList().iterator(); iter.hasNext();) {
+ FileSet fileSet = (FileSet) iter.next();
+ sourceRepos.add(fileSet);
+ // Added to the application later through prepareSourceRepos
}
}
@@ -113,38 +123,39 @@ public abstract class AbstractRepositoryTask extends Task {
if (sourceRepos == null || sourceRepos.isEmpty())
return;
for (Iterator iter = sourceRepos.iterator(); iter.hasNext();) {
- Object next = iter.next();
- if (next instanceof MyFileSet) {
- MyFileSet fileset = (MyFileSet) next;
- // determine if the user set a "location" attribute or used a fileset
- if (fileset.location == null) {
- DirectoryScanner scanner = fileset.getDirectoryScanner(getProject());
- String[][] elements = new String[][] {scanner.getIncludedDirectories(), scanner.getIncludedFiles()};
- for (int i = 0; i < 2; i++) {
- for (int j = 0; j < elements[i].length; j++) {
- File file = new File(fileset.getDir(), elements[i][j]);
- URI uri = file.toURI();
-
- if (file.isFile() && file.getName().endsWith(".zip")) { //$NON-NLS-1$
- try {
- uri = new URI("jar:" + uri.toString() + "!/"); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (URISyntaxException e) {
- //?
- continue;
- }
- }
- application.addSourceArtifactRepository(uri);
- application.addSourceMetadataRepository(uri);
+ RepositoryFileSet fileset = (RepositoryFileSet) iter.next();
+
+ if (fileset.getRepoLocation() != null) {
+ //TODO depreciate
+ if (!fileset.getRepoLocation().startsWith(ANT_PREFIX)) {
+ addArtifactSourceRepository(fileset.getRepoLocationURI());
+ addMetadataSourceRepository(fileset.getRepoLocationURI());
+ }
+ } else if (fileset.getDir() != null) {
+ DirectoryScanner scanner = fileset.getDirectoryScanner(getProject());
+ String[][] elements = new String[][] {scanner.getIncludedDirectories(), scanner.getIncludedFiles()};
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < elements[i].length; j++) {
+ File file = new File(fileset.getDir(), elements[i][j]);
+ URI uri = file.toURI();
+
+ if (file.isFile() && file.getName().endsWith(".zip")) { //$NON-NLS-1$
+ uri = URIUtil.toJarURI(uri, null);
}
- }
- } else {
- if (!fileset.location.startsWith(ANT_PREFIX)) {
- application.addSourceArtifactRepository(fileset.location);
- application.addSourceMetadataRepository(fileset.location);
+ if (fileset.isBoth()) {
+ addArtifactSourceRepository(uri);
+ addMetadataSourceRepository(uri);
+ } else if (fileset.isArtifact())
+ addArtifactSourceRepository(uri);
+ else if (fileset.isMetadata())
+ addMetadataSourceRepository(uri);
+ else
+ throw new BuildException(NLS.bind(Messages.unknown_repository_type, uri));
}
}
}
}
+ sourceRepos.clear();
}
protected List prepareIUs() {
@@ -161,9 +172,17 @@ public abstract class AbstractRepositoryTask extends Task {
repository.query(iuQuery, collector, null);
if (iu.isRequired() && collector.isEmpty())
- throw new BuildException("Unable to find: " + iu.toString()); //$NON-NLS-1$
+ throw new BuildException(NLS.bind(Messages.AbstractRepositoryTask_unableToFind, iu.toString()));
result.addAll(collector.toCollection());
}
return result;
}
+
+ protected void log(IStatus status) {
+ try {
+ new AntMirrorLog(this).log(status);
+ } catch (NoSuchMethodException e) {
+ // Shouldn't occur
+ }
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ComparatorDescription.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ComparatorDescription.java
new file mode 100644
index 000000000..9ec3fc38b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ComparatorDescription.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.internal.repository.tools.tasks;
+
+import java.io.File;
+import org.apache.tools.ant.types.DataType;
+
+public class ComparatorDescription extends DataType {
+
+ DestinationRepository baseline;
+ String comparatorId;
+ File comparatorLog;
+
+ /*
+ * Set the baseline repository to compare to
+ */
+ public void addRepository(DestinationRepository value) {
+ this.baseline = value;
+ }
+
+ /*
+ * Set the comparator to use
+ */
+ public void setComparator(String value) {
+ comparatorId = value;
+ }
+
+ /*
+ * Set the log location for the comparator
+ */
+ public void setComparatorLog(File value) {
+ comparatorLog = value;
+ }
+
+ public DestinationRepository getBaseline() {
+ return baseline;
+ }
+
+ public String getComparator() {
+ return comparatorId;
+ }
+
+ public File getComparatorLog() {
+ return comparatorLog;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CompositeRepositoryTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CompositeRepositoryTask.java
new file mode 100644
index 000000000..ec674dcc4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CompositeRepositoryTask.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.internal.repository.tools.tasks;
+
+import java.util.Iterator;
+import org.apache.tools.ant.BuildException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.internal.repository.tools.CompositeRepositoryApplication;
+
+public class CompositeRepositoryTask extends AbstractRepositoryTask {
+
+ public CompositeRepositoryTask() {
+ application = new CompositeRepositoryApplication();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() throws BuildException {
+ try {
+ IStatus result = application.run(null);
+ if (result.matches(IStatus.ERROR)) {
+ throw new BuildException(TaskHelper.statusToString(result, null).toString());
+ }
+ } catch (ProvisionException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ /*
+ * Add the listed repositories to the composite repository
+ */
+ public void addConfiguredAdd(RepositoryList list) {
+ for (Iterator iter = list.getRepositoryList().iterator(); iter.hasNext();) {
+ DestinationRepository repo = (DestinationRepository) iter.next();
+ ((CompositeRepositoryApplication) application).addChild(repo.getDescriptor());
+ }
+ }
+
+ /*
+ * Remove the listed repositories from the composite repository
+ */
+ public void addConfiguredRemove(RepositoryList list) {
+ for (Iterator iter = list.getRepositoryList().iterator(); iter.hasNext();) {
+ DestinationRepository repo = (DestinationRepository) iter.next();
+ ((CompositeRepositoryApplication) application).removeChild(repo.getDescriptor());
+ }
+ }
+
+ /*
+ * Set whether the task should fail if the repository already exists
+ */
+ public void setFailOnExists(boolean value) {
+ ((CompositeRepositoryApplication) application).setFailOnExists(value);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/DestinationRepository.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/DestinationRepository.java
index 351529930..71602d595 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/DestinationRepository.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/DestinationRepository.java
@@ -36,8 +36,12 @@ public class DestinationRepository extends DataType {
}
}
- public void setFormat(String format) {
- descriptor.setFormat(format);
+ public void setFormat(String formatLocation) {
+ try {
+ descriptor.setFormat(URIUtil.fromString(formatLocation));
+ } catch (URISyntaxException e) {
+ throw new BuildException(e);
+ }
}
public void setAppend(boolean appendMode) {
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java
index 06699c1a5..fceaaf32a 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java
@@ -10,32 +10,57 @@
*******************************************************************************/
package org.eclipse.equinox.p2.internal.repository.tools.tasks;
+import java.io.File;
import java.util.List;
import org.apache.tools.ant.BuildException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.p2.artifact.repository.ant.AntMirrorLog;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.internal.repository.tools.Messages;
import org.eclipse.equinox.p2.internal.repository.tools.MirrorApplication;
public class MirrorTask extends AbstractRepositoryTask {
+ private File mirrorLog; // file to log mirror output to (optional)
+ private ComparatorDescription comparator;
+
public MirrorTask() {
application = new MirrorApplication();
}
public void execute() throws BuildException {
try {
+ if (mirrorLog != null)
+ ((MirrorApplication) application).setLog(mirrorLog);
+ else
+ ((MirrorApplication) application).setLog(new AntMirrorLog(this));
+
+ if (comparator != null) {
+ // Enable comparison
+ ((MirrorApplication) application).setCompare(true);
+ // Set baseline location
+ if (comparator.getBaseline() != null)
+ ((MirrorApplication) application).setBaseline(comparator.getBaseline().getDescriptor().getRepoLocation());
+ // Set comparator to use
+ if (comparator.getComparator() != null)
+ ((MirrorApplication) application).setComparatorID(comparator.getComparator());
+ // Set comparator log
+ if (comparator.getComparatorLog() != null)
+ ((MirrorApplication) application).setComparatorLog(comparator.getComparatorLog());
+ }
+
prepareSourceRepos();
application.initializeRepos(null);
List ius = prepareIUs();
- if (ius == null || ius.size() == 0)
- throw new BuildException("Need to specify one or more IUs to mirror.");
application.setSourceIUs(ius);
IStatus result = application.run(null);
- if (result.matches(IStatus.ERROR)) {
+ if (result.matches(IStatus.ERROR))
throw new BuildException(TaskHelper.statusToString(result, null).toString());
- }
} catch (ProvisionException e) {
throw new BuildException(e);
+ } catch (NoSuchMethodException e) {
+ // Should not occur
+ throw new BuildException(e);
}
}
@@ -44,4 +69,46 @@ public class MirrorTask extends AbstractRepositoryTask {
((MirrorApplication) application).setSlicingOptions(options.getOptions());
return options;
}
+
+ /*
+ * Set the comparison information
+ */
+ public ComparatorDescription createComparator() {
+ if (comparator != null)
+ throw new BuildException(Messages.exception_onlyOneComparator);
+ comparator = new ComparatorDescription();
+ return comparator;
+ }
+
+ /*
+ * Set the location of the mirror log
+ */
+ public void setLog(String value) {
+ mirrorLog = new File(value);
+ }
+
+ /*
+ * Set whether or not we should ignore errors when running the mirror application.
+ */
+ public void setIgnoreErrors(boolean value) {
+ ((MirrorApplication) application).setIgnoreErrors(value);
+ }
+
+ /*
+ * Set whether or not the the artifacts are raw.
+ */
+ public void setRaw(boolean value) {
+ ((MirrorApplication) application).setRaw(value);
+ }
+
+ /*
+ * Set whether or not the mirror application should be run in verbose mode.
+ */
+ public void setVerbose(boolean value) {
+ ((MirrorApplication) application).setVerbose(value);
+ }
+
+ public void setValidate(boolean value) {
+ ((MirrorApplication) application).setValidate(value);
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java
index 9415092c5..9e8947335 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java
@@ -21,8 +21,8 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.jarprocessor.ant.JarProcessorTask;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.internal.repository.tools.RecreateRepositoryApplication;
-import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor;
+import org.eclipse.equinox.p2.internal.repository.tools.*;
+import org.eclipse.osgi.util.NLS;
public class ProcessRepoTask extends Task {
@@ -64,7 +64,7 @@ public class ProcessRepoTask extends Task {
public void execute() throws BuildException {
File file = URIUtil.toFile(repository);
if (file == null || !file.exists()) {
- throw new BuildException("Repository must be local: " + repository.toString()); //$NON-NLS-1$
+ throw new BuildException(NLS.bind(Messages.ProcessRepo_must_be_local, repository.toString()));
}
if (pack | repack | signing != null) {
if (jarProcessor == null)
@@ -113,7 +113,7 @@ public class ProcessRepoTask extends Task {
try {
this.repository = URIUtil.fromString(repository);
} catch (URISyntaxException e) {
- throw new IllegalArgumentException("Repository location (" + repository + ") must be a URL."); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new IllegalArgumentException(NLS.bind(Messages.ProcessRepo_location_not_url, repository));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java
index 5c84ff036..d3fb10cdb 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java
@@ -44,7 +44,7 @@ public class Repo2RunnableTask extends AbstractRepositoryTask {
prepareSourceRepos();
application.initializeRepos(null);
List ius = prepareIUs();
- if ((ius == null || ius.size() == 0) && (sourceRepos == null || sourceRepos.isEmpty()))
+ if ((ius == null || ius.size() == 0) && !(application.hasArtifactSources() || application.hasMetadataSources()))
throw new BuildException("Need to specify either a non-empty source metadata repository or a valid list of IUs.");
application.setSourceIUs(ius);
IStatus result = application.run(null);
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryFileSet.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryFileSet.java
new file mode 100644
index 000000000..c7e88ddf4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryFileSet.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.internal.repository.tools.tasks;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.FileSet;
+import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper;
+import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
+import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor;
+
+public class RepositoryFileSet extends FileSet {
+ public final static int TYPE_ARTIFACT = IRepository.TYPE_ARTIFACT;
+ public final static int TYPE_METADATA = IRepository.TYPE_METADATA;
+
+ private int kind = RepositoryDescriptor.TYPE_BOTH;
+ protected String myLocation = null;
+
+ public void setKind(String repoKind) {
+ kind = RepositoryDescriptor.determineKind(repoKind);
+ }
+
+ public int getKind() {
+ return kind;
+ }
+
+ public boolean isBoth() {
+ return kind == RepositoryDescriptor.TYPE_BOTH;
+ }
+
+ public boolean isArtifact() {
+ return kind == RepositoryDescriptor.TYPE_BOTH || kind == IRepository.TYPE_ARTIFACT;
+ }
+
+ public boolean isMetadata() {
+ return kind == RepositoryDescriptor.TYPE_BOTH || kind == IRepository.TYPE_METADATA;
+ }
+
+ public void setLocation(String value) {
+ // TODO depreciate
+ myLocation = value;
+ }
+
+ public String getRepoLocation() {
+ // TODO depreciate
+ return myLocation;
+ }
+
+ public URI getRepoLocationURI() {
+ // TODO depreciate
+ try {
+ return RepositoryHelper.localRepoURIHelper(URIUtil.fromString(getRepoLocation()));
+ } catch (URISyntaxException e) {
+ throw new BuildException(e);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryList.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryList.java
new file mode 100644
index 000000000..a76d3218d
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryList.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.internal.repository.tools.tasks;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class RepositoryList extends RepositoryFileSet {
+ // TODO this class should extend DataType, currently RepoFileSet to support <source location="xxx" />
+ List repositories = new ArrayList();
+ List sourceFileSets = new ArrayList();
+
+ public DestinationRepository createRepository() {
+ DestinationRepository repo = new DestinationRepository();
+ repositories.add(repo);
+ return repo;
+ }
+
+ public RepositoryFileSet createFileSet() {
+ RepositoryFileSet fileSet = new RepositoryFileSet();
+ sourceFileSets.add(fileSet);
+ return fileSet;
+ }
+
+ public List getRepositoryList() {
+ return repositories;
+ }
+
+ public List getFileSetList() {
+ //TODO this should eventually be removed
+ sourceFileSets.add(this);
+ return sourceFileSets;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SlicingOption.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SlicingOption.java
index 50b1eb035..37d5f9089 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SlicingOption.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SlicingOption.java
@@ -13,7 +13,9 @@ package org.eclipse.equinox.p2.internal.repository.tools.tasks;
import java.util.*;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
+import org.eclipse.equinox.p2.internal.repository.tools.Messages;
import org.eclipse.equinox.p2.internal.repository.tools.SlicingOptions;
+import org.eclipse.osgi.util.NLS;
public class SlicingOption extends Task {
@@ -51,7 +53,7 @@ public class SlicingOption extends Task {
}
StringTokenizer tok = new StringTokenizer(platformFilter, ","); //$NON-NLS-1$
if (tok.countTokens() != 3)
- throw new BuildException("Invalid platform filter format: " + platformFilter + ".");
+ throw new BuildException(NLS.bind(Messages.SlicingOption_invalid_platform, platformFilter));
Dictionary filter = options.getFilter();
if (filter == null)
filter = new Properties();

Back to the top