Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 255913 | Differences between
and this patch

Collapse All | Expand All

(-).classpath (+1 lines)
Lines 3-7 Link Here
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="src" output="bin_ant" path="src_ant"/>
6
	<classpathentry kind="output" path="bin"/>
7
	<classpathentry kind="output" path="bin"/>
7
</classpath>
8
</classpath>
(-)plugin.xml (+38 lines)
Lines 43-46 Link Here
43
		<artifactComparator class="org.eclipse.equinox.internal.p2.artifact.processors.md5.MD5ArtifactComparator"
43
		<artifactComparator class="org.eclipse.equinox.internal.p2.artifact.processors.md5.MD5ArtifactComparator"
44
		id="org.eclipse.equinox.artifact.md5.comparator"/>
44
		id="org.eclipse.equinox.artifact.md5.comparator"/>
45
	</extension>
45
	</extension>
46
	
47
	<extension point="org.eclipse.ant.core.antTasks">
48
		<antTask
49
			library="ant_tasks/artifactRepository-ant.jar"
50
			name="eclipse.p2.artifactMirrorApplication"
51
			class="org.eclipse.equinox.internal.p2.artifact.repository.ant.MirrorApplicationTask">
52
		</antTask>
53
		
54
		<antTask
55
			library="ant_tasks/artifactRepository-ant.jar"
56
			name="eclipse.p2.CompositeArtifactRepository.create"
57
			class="org.eclipse.equinox.internal.p2.artifact.repository.ant.CreateCompositeArtifactRepositoryTask">
58
		</antTask>
59
		
60
		<antTask
61
			library="ant_tasks/artifactRepository-ant.jar"
62
			name="eclipse.p2.CompositeArtifactRepository.addChild"
63
			class="org.eclipse.equinox.internal.p2.artifact.repository.ant.AddChildTask">
64
		</antTask>
65
		
66
		<antTask
67
			library="ant_tasks/artifactRepository-ant.jar"
68
			name="eclipse.p2.CompositeArtifactRepository.removeChild"
69
			class="org.eclipse.equinox.internal.p2.artifact.repository.ant.RemoveChildTask">
70
		</antTask>
71
		
72
		<antTask
73
			library="ant_tasks/artifactRepository-ant.jar"
74
			name="eclipse.p2.CompositeArtifactRepository.removeAllChildren"
75
			class="org.eclipse.equinox.internal.p2.artifact.repository.ant.RemoveAllChildrenTask">
76
		</antTask>
77
		
78
		<antTask
79
			library="ant_tasks/artifactRepository-ant.jar"
80
			name="eclipse.p2.CompositeArtifactRepository.sanityCheck"
81
			class="org.eclipse.equinox.internal.p2.artifact.repository.ant.SanityCheckTask">
82
		</antTask>
83
	</extension>
46
</plugin>
84
</plugin>
(-)build.properties (-1 / +7 lines)
Lines 14-19 Link Here
14
               .,\
14
               .,\
15
               plugin.xml,\
15
               plugin.xml,\
16
               about.html,\
16
               about.html,\
17
               plugin.properties
17
               plugin.properties,\
18
               ant_tasks/artifactRepository-ant.jar
18
src.includes = about.html,\
19
src.includes = about.html,\
19
               schema/
20
               schema/
21
jars.extra.classpath = platform:/plugin/org.apache.ant/lib/ant.jar
22
jars.compile.order = .,\
23
                     ant_tasks/artifactRepository-ant.jar
24
source.ant_tasks/artifactRepository-ant.jar = src_ant/
25
output.ant_tasks/artifactRepository-ant.jar = bin_ant/
(-).project (+10 lines)
Lines 20-25 Link Here
20
			<arguments>
20
			<arguments>
21
			</arguments>
21
			</arguments>
22
		</buildCommand>
22
		</buildCommand>
23
		<buildCommand>
24
			<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
25
			<triggers>full,incremental,</triggers>
26
			<arguments>
27
				<dictionary>
28
					<key>LaunchConfigHandle</key>
29
					<value>&lt;project&gt;/.externalToolBuilders/org.eclipse.equinox.p2.artifact.repository buildAntTasks.xml.launch</value>
30
				</dictionary>
31
			</arguments>
32
		</buildCommand>
23
	</buildSpec>
33
	</buildSpec>
24
	<natures>
34
	<natures>
25
		<nature>org.eclipse.pde.PluginNature</nature>
35
		<nature>org.eclipse.pde.PluginNature</nature>
(-)src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/CreateCompositeArtifactRepositoryTask.java (+65 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.equinox.internal.p2.artifact.repository.ant;
13
14
import java.net.URI;
15
import java.net.URISyntaxException;
16
import java.util.HashMap;
17
import java.util.Map;
18
import org.apache.tools.ant.BuildException;
19
import org.apache.tools.ant.Task;
20
import org.eclipse.core.runtime.URIUtil;
21
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
22
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
23
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
24
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
25
import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository;
26
27
public class CreateCompositeArtifactRepositoryTask extends Task {
28
	URI location; //desired location of the composite repository
29
	String name = "Composite Artifact Repository";
30
	boolean compressed = true;
31
	Map properties = new HashMap();
32
33
	public void execute() {
34
		IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
35
		if (manager == null)
36
			throw new BuildException("Unable to aquire RepositoryManager.");
37
38
		//remove the repo first.
39
		manager.removeRepository(location);
40
41
		//create the properties
42
		if (compressed)
43
			properties.put(IRepository.PROP_COMPRESSED, "true");
44
45
		//create the repository
46
		try {
47
			manager.createRepository(location, name, IArtifactRepositoryManager.TYPE_COMPOSITE_REPOSITORY, properties);
48
		} catch (ProvisionException e) {
49
			throw new BuildException("Exception while creating composite artifact repository.", e);
50
		}
51
	}
52
53
	public void setName(String value) {
54
		name = value;
55
	}
56
57
	public void setLocation(String value) throws URISyntaxException {
58
		location = URIUtil.fromString(value);
59
	}
60
61
	public void setCompressed(boolean value) {
62
		compressed = value;
63
	}
64
65
}
(-)src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/MirrorApplicationTask.java (+135 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.equinox.internal.p2.artifact.repository.ant;
13
14
import java.net.MalformedURLException;
15
import java.net.URL;
16
import java.util.HashMap;
17
import java.util.Map;
18
import org.apache.tools.ant.BuildException;
19
import org.apache.tools.ant.Task;
20
import org.eclipse.equinox.app.IApplicationContext;
21
import org.eclipse.equinox.internal.p2.artifact.mirror.MirrorApplication;
22
import org.osgi.framework.Bundle;
23
24
public class MirrorApplicationTask extends Task {
25
	URL source;
26
	URL destination;
27
	URL baseline; //location of known good repository for compare against. Not required
28
	String comparatorID; //specifies a comparator. Not required
29
	String message = "";
30
	String writeMode;
31
	boolean compare = false;
32
	boolean ignoreErrors = false;
33
	boolean raw = false; //use raw artifact descriptors?
34
	boolean verbose = false;
35
36
	/**
37
	 * runs the mirror application with arguments args
38
	 */
39
	private void runMirrorApplication(String msg, final String[] args) throws Exception {
40
		MirrorApplication application = new MirrorApplication();
41
		application.start(new IApplicationContext() {
42
43
			public void applicationRunning() {
44
			}
45
46
			public Map getArguments() {
47
				Map arguments = new HashMap();
48
49
				arguments.put(IApplicationContext.APPLICATION_ARGS, args);
50
51
				return arguments;
52
			}
53
54
			public String getBrandingApplication() {
55
				return null;
56
			}
57
58
			public Bundle getBrandingBundle() {
59
				return null;
60
			}
61
62
			public String getBrandingDescription() {
63
				return null;
64
			}
65
66
			public String getBrandingId() {
67
				return null;
68
			}
69
70
			public String getBrandingName() {
71
				return null;
72
			}
73
74
			public String getBrandingProperty(String key) {
75
				return null;
76
			}
77
		});
78
	}
79
80
	public void execute() {
81
		//Compare against if baseline specified
82
		boolean compareAgainst = baseline != null;
83
		boolean comparator = comparatorID != null;
84
		//create arguments
85
		String[] args = new String[] {"-source", source.toExternalForm(), "-destination", destination.toExternalForm(), "-writeMode", writeMode == null ? "" : writeMode, compare ? "-compare" : "", ignoreErrors ? "-ignoreErrors" : "", raw ? "-raw" : "", verbose ? "-verbose" : "", compareAgainst ? "-compareAgainst" : "", compareAgainst ? baseline.toExternalForm() : "", comparator ? "-comparator" : "", comparator ? comparatorID : ""};
86
87
		try {
88
			runMirrorApplication(message, args);
89
		} catch (Exception e) {
90
			throw new BuildException("Exception while running mirror application.", e);
91
		}
92
	}
93
94
	public void setSource(String value) throws MalformedURLException {
95
		source = new URL(value);
96
	}
97
98
	public void setDestination(String value) throws MalformedURLException {
99
		destination = new URL(value);
100
	}
101
102
	public void setBaseline(String value) throws MalformedURLException {
103
		baseline = new URL(value);
104
		compare = true;
105
	}
106
107
	public void setComparatorID(String value) {
108
		comparatorID = value;
109
		compare = true;
110
	}
111
112
	public void setMessage(String value) {
113
		message = value;
114
	}
115
116
	public void setWriteMode(String value) {
117
		writeMode = value;
118
	}
119
120
	public void setCompare(boolean value) {
121
		compare = value;
122
	}
123
124
	public void setIgnoreErrors(boolean value) {
125
		ignoreErrors = value;
126
	}
127
128
	public void setRaw(boolean value) {
129
		raw = value;
130
	}
131
132
	public void setVerbose(boolean value) {
133
		verbose = value;
134
	}
135
}
(-)src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveAllChildrenTask.java (+48 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.equinox.internal.p2.artifact.repository.ant;
13
14
import java.net.URI;
15
import java.net.URISyntaxException;
16
import org.apache.tools.ant.BuildException;
17
import org.apache.tools.ant.Task;
18
import org.eclipse.core.runtime.URIUtil;
19
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
20
import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository;
21
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
22
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
23
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
24
25
public class RemoveAllChildrenTask extends Task {
26
	URI location; //location of the composite repository
27
28
	public void execute() {
29
		IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
30
		if (manager == null)
31
			throw new BuildException("Unable to aquire RepositoryManager.");
32
33
		//load repository
34
		CompositeArtifactRepository repo = null;
35
		try {
36
			repo = (CompositeArtifactRepository) manager.loadRepository(location, null);
37
		} catch (ProvisionException e) {
38
			throw new BuildException("Exception while loading repository.", e);
39
		}
40
41
		//remove all children
42
		repo.removeAllChildren();
43
	}
44
45
	public void setLocation(String value) throws URISyntaxException {
46
		location = URIUtil.fromString(value);
47
	}
48
}
(-)src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AddChildTask.java (+65 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.equinox.internal.p2.artifact.repository.ant;
13
14
import java.net.URI;
15
import java.net.URISyntaxException;
16
import org.apache.tools.ant.BuildException;
17
import org.apache.tools.ant.Task;
18
import org.eclipse.core.runtime.URIUtil;
19
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
20
import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository;
21
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
22
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
23
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
24
25
public class AddChildTask extends Task {
26
	URI location; //location of the composite repository
27
	URI child; //address of the child to add
28
	String comparatorID; //comparator to use for compare. Not required
29
30
	public void execute() {
31
		IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
32
		if (manager == null)
33
			throw new BuildException("Unable to aquire RepositoryManager.");
34
35
		//get the composite repository
36
		CompositeArtifactRepository repo = null;
37
		try {
38
			repo = (CompositeArtifactRepository) manager.loadRepository(location, null);
39
		} catch (ProvisionException e) {
40
			throw new BuildException("Exception while loading repository.", e);
41
		}
42
43
		//assumes that specifying a comparatorID means we want to compare
44
		if (comparatorID != null) {
45
			if (repo.addChild(child, comparatorID))
46
				System.out.println(child + " was added successfully");
47
			else
48
				System.out.println(child + " was not added");
49
		} else {
50
			repo.addChild(child);
51
		}
52
	}
53
54
	public void setLocation(String value) throws URISyntaxException {
55
		location = URIUtil.fromString(value);
56
	}
57
58
	public void setChild(String value) throws URISyntaxException {
59
		child = URIUtil.fromString(value);
60
	}
61
62
	public void setComparatorID(String value) {
63
		comparatorID = value;
64
	}
65
}
(-)src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/ValidateTask.java (+55 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.equinox.internal.p2.artifact.repository.ant;
13
14
import java.net.URI;
15
import java.net.URISyntaxException;
16
import org.apache.tools.ant.BuildException;
17
import org.eclipse.core.runtime.URIUtil;
18
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
19
import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository;
20
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
21
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
22
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
23
24
public class ValidateTask {
25
	URI location; //location of the composite repository
26
	String comparatorID; //specifies the comparator we want to use.
27
28
	public void execute() {
29
		IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
30
		if (manager == null)
31
			throw new BuildException("Unable to aquire RepositoryManager.");
32
33
		//load the repository
34
		CompositeArtifactRepository repo = null;
35
		try {
36
			repo = (CompositeArtifactRepository) manager.loadRepository(location, null);
37
		} catch (ProvisionException e) {
38
			throw new BuildException("Exception while loading repository.", e);
39
		}
40
41
		//perform the sanity check
42
		if (repo.validate(comparatorID))
43
			System.err.println("Sanity Check is OK");
44
		else
45
			System.err.println("Sanity Check failed");
46
	}
47
48
	public void setLocation(String value) throws URISyntaxException {
49
		location = URIUtil.fromString(value);
50
	}
51
52
	public void setComparatorID(String value) {
53
		comparatorID = value;
54
	}
55
}
(-)src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveChildTask.java (+51 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.equinox.internal.p2.artifact.repository.ant;
13
14
import java.net.URI;
15
import java.net.URISyntaxException;
16
import org.apache.tools.ant.BuildException;
17
import org.apache.tools.ant.Task;
18
import org.eclipse.core.runtime.URIUtil;
19
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
20
import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository;
21
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
22
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
23
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
24
25
public class RemoveChildTask extends Task {
26
	URI location; //location of the composite repository
27
	URI child; //address of child to remove
28
29
	public void execute() {
30
		IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
31
32
		//load repository
33
		CompositeArtifactRepository repo;
34
		try {
35
			repo = (CompositeArtifactRepository) manager.loadRepository(location, null);
36
		} catch (ProvisionException e) {
37
			throw new BuildException("Exception while loading repository.", e);
38
		}
39
40
		//remove the child
41
		repo.removeChild(child);
42
	}
43
44
	public void setLocation(String value) throws URISyntaxException {
45
		location = URIUtil.fromString(value);
46
	}
47
48
	public void setChild(String value) throws URISyntaxException {
49
		child = URIUtil.fromString(value);
50
	}
51
}
(-)build.properties (-1 / +7 lines)
Lines 14-19 Link Here
14
               .,\
14
               .,\
15
               about.html,\
15
               about.html,\
16
               plugin.xml,\
16
               plugin.xml,\
17
               plugin.properties
17
               plugin.properties,\
18
               ant_tasks/metadataRepository-ant.jar
18
src.includes = about.html,\
19
src.includes = about.html,\
19
               schema/
20
               schema/
21
jars.extra.classpath = platform:/plugin/org.apache.ant/lib/ant.jar
22
jars.compile.order = .,\
23
                     ant_tasks/metadataRepository-ant.jar
24
source.ant_tasks/metadataRepository-ant.jar = src_ant/
25
output.ant_tasks/metadataRepository-ant.jar = bin_ant/
(-)plugin.xml (+32 lines)
Lines 22-25 Link Here
22
        <filter suffix="compositeContent.xml"/>
22
        <filter suffix="compositeContent.xml"/>
23
        <factory class="org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepositoryFactory"/>
23
        <factory class="org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepositoryFactory"/>
24
   </extension>
24
   </extension>
25
   
26
   <extension point="org.eclipse.ant.core.antTasks">
27
   		<antTask
28
			library="ant_tasks/metadataRepository-ant.jar"
29
			name="eclipse.p2.metadataMirrorApplication"
30
			class="org.eclipse.equinox.internal.p2.metadata.repository.ant.MirrorApplicationTask">
31
		</antTask>
32
		
33
		<antTask
34
			library="ant_tasks/metadataRepository-ant.jar"
35
			name="eclipse.p2.CompositeMetadataRepository.create"
36
			class="org.eclipse.equinox.internal.p2.metadata.repository.ant.CreateCompositeMetadataRepositoryTask">
37
		</antTask>
38
		
39
		<antTask
40
			library="ant_tasks/metadataRepository-ant.jar"
41
			name="eclipse.p2.CompositeMetadataRepository.addChild"
42
			class="org.eclipse.equinox.internal.p2.metadata.repository.ant.AddChildTask">
43
		</antTask>
44
		
45
		<antTask
46
			library="ant_tasks/metadataRepository-ant.jar"
47
			name="eclipse.p2.CompositeMetadataRepository.removeChild"
48
			class="org.eclipse.equinox.internal.p2.metadata.repository.ant.RemoveChildTask">
49
		</antTask>
50
		
51
		<antTask
52
			library="ant_tasks/metadataRepository-ant.jar"
53
			name="eclipse.p2.CompositeMetadataRepository.removeAllChildren"
54
			class="org.eclipse.equinox.internal.p2.metadata.repository.ant.RemoveAllChildrenTask">
55
		</antTask>
56
	</extension>
25
</plugin>
57
</plugin>
(-).classpath (+1 lines)
Lines 3-7 Link Here
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="src" output="bin_ant" path="src_ant"/>
6
	<classpathentry kind="output" path="bin"/>
7
	<classpathentry kind="output" path="bin"/>
7
</classpath>
8
</classpath>
(-).project (+10 lines)
Lines 25-30 Link Here
25
			<arguments>
25
			<arguments>
26
			</arguments>
26
			</arguments>
27
		</buildCommand>
27
		</buildCommand>
28
		<buildCommand>
29
			<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
30
			<triggers>full,incremental,</triggers>
31
			<arguments>
32
				<dictionary>
33
					<key>LaunchConfigHandle</key>
34
					<value>&lt;project&gt;/.externalToolBuilders/org.eclipse.equinox.p2.metadata.reposiroy buildAntTasks.xml.launch</value>
35
				</dictionary>
36
			</arguments>
37
		</buildCommand>
28
	</buildSpec>
38
	</buildSpec>
29
	<natures>
39
	<natures>
30
		<nature>org.eclipse.pde.PluginNature</nature>
40
		<nature>org.eclipse.pde.PluginNature</nature>
(-)src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java (+55 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.equinox.internal.p2.metadata.repository.ant;
13
14
import java.net.URI;
15
import java.net.URISyntaxException;
16
import org.apache.tools.ant.BuildException;
17
import org.apache.tools.ant.Task;
18
import org.eclipse.core.runtime.URIUtil;
19
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
20
import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
21
import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
22
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
23
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
24
25
public class AddChildTask extends Task {
26
	URI location; //location of the composite repository
27
	URI child; //address of the child to add
28
29
	public void execute() {
30
		IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
31
		if (manager == null)
32
			throw new BuildException("Unable to aquire RepositoryManager.");
33
34
		//load the composite repository
35
		CompositeMetadataRepository repo = null;
36
		try {
37
			repo = (CompositeMetadataRepository) manager.loadRepository(location, null);
38
		} catch (ProvisionException e) {
39
			throw new BuildException("Exception while loading repository.", e);
40
		}
41
42
		//add the child
43
		repo.addChild(child);
44
45
		manager.removeRepository(location);
46
	}
47
48
	public void setLocation(String value) throws URISyntaxException {
49
		location = URIUtil.fromString(value);
50
	}
51
52
	public void setChild(String value) throws URISyntaxException {
53
		child = URIUtil.fromString(value);
54
	}
55
}
(-)src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java (+48 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.equinox.internal.p2.metadata.repository.ant;
13
14
import java.net.URI;
15
import java.net.URISyntaxException;
16
import org.apache.tools.ant.BuildException;
17
import org.apache.tools.ant.Task;
18
import org.eclipse.core.runtime.URIUtil;
19
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
20
import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
21
import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
22
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
23
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
24
25
public class RemoveChildTask extends Task {
26
	URI location; //location of the composite repository
27
	URI child; //address of the child to be removed
28
29
	public void execute() {
30
		IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
31
32
		CompositeMetadataRepository repo;
33
		try {
34
			repo = (CompositeMetadataRepository) manager.loadRepository(location, null);
35
		} catch (ProvisionException e) {
36
			throw new BuildException("Exception while loading repository.", e);
37
		}
38
		repo.removeChild(child);
39
	}
40
41
	public void setLocation(String value) throws URISyntaxException {
42
		location = URIUtil.fromString(value);
43
	}
44
45
	public void setChild(String value) throws URISyntaxException {
46
		child = URIUtil.fromString(value);
47
	}
48
}
(-)src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveAllChildrenTask.java (+48 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.equinox.internal.p2.metadata.repository.ant;
13
14
import java.net.URI;
15
import java.net.URISyntaxException;
16
import org.apache.tools.ant.BuildException;
17
import org.apache.tools.ant.Task;
18
import org.eclipse.core.runtime.URIUtil;
19
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
20
import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
21
import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
22
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
23
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
24
25
public class RemoveAllChildrenTask extends Task {
26
	URI location; //location of the composite repository
27
28
	public void execute() {
29
		IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
30
		if (manager == null)
31
			throw new BuildException("Unable to aquire RepositoryManager.");
32
33
		//load the repository
34
		CompositeMetadataRepository repo = null;
35
		try {
36
			repo = (CompositeMetadataRepository) manager.loadRepository(location, null);
37
		} catch (ProvisionException e) {
38
			throw new BuildException("Exception while loading repository.", e);
39
		}
40
41
		//remove all children
42
		repo.removeAllChildren();
43
	}
44
45
	public void setLocation(String value) throws URISyntaxException {
46
		location = URIUtil.fromString(value);
47
	}
48
}
(-)src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java (+65 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.equinox.internal.p2.metadata.repository.ant;
13
14
import java.net.URI;
15
import java.net.URISyntaxException;
16
import java.util.HashMap;
17
import java.util.Map;
18
import org.apache.tools.ant.BuildException;
19
import org.apache.tools.ant.Task;
20
import org.eclipse.core.runtime.URIUtil;
21
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
22
import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
23
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
24
import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository;
25
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
26
27
public class CreateCompositeMetadataRepositoryTask extends Task {
28
	URI location; //desired location of the composite repository
29
	String name = "Composite Metadata Repository";
30
	boolean compressed = true;
31
	Map properties = new HashMap();
32
33
	public void execute() {
34
		IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
35
		if (manager == null)
36
			throw new BuildException("Unable to aquire RepositoryManager.");
37
38
		//remove the repo first.
39
		manager.removeRepository(location);
40
41
		//create the properties
42
		if (compressed)
43
			properties.put(IRepository.PROP_COMPRESSED, "true");
44
45
		//create the repository
46
		try {
47
			manager.createRepository(location, name, IMetadataRepositoryManager.TYPE_COMPOSITE_REPOSITORY, properties);
48
		} catch (ProvisionException e) {
49
			throw new BuildException("Exception while creating composite artifact repository.", e);
50
		}
51
	}
52
53
	public void setName(String value) {
54
		name = value;
55
	}
56
57
	public void setLocation(String value) throws URISyntaxException {
58
		location = URIUtil.fromString(value);
59
	}
60
61
	public void setCompressed(boolean value) {
62
		compressed = value;
63
	}
64
65
}
(-)src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/MirrorApplicationTask.java (+102 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.equinox.internal.p2.metadata.repository.ant;
13
14
import java.net.MalformedURLException;
15
import java.net.URL;
16
import java.util.HashMap;
17
import java.util.Map;
18
import org.apache.tools.ant.BuildException;
19
import org.apache.tools.ant.Task;
20
import org.eclipse.equinox.app.IApplicationContext;
21
import org.eclipse.equinox.internal.p2.metadata.mirror.MirrorApplication;
22
import org.osgi.framework.Bundle;
23
24
public class MirrorApplicationTask extends Task {
25
	URL source;
26
	URL destination;
27
	String message = "";
28
	String writeMode;
29
30
	//TODO add transitive and roots attributed when implemented.
31
32
	/**
33
	 * runs the mirror application with arguments args
34
	 */
35
	private void runMirrorApplication(String msg, final String[] args) throws Exception {
36
		MirrorApplication application = new MirrorApplication();
37
		application.start(new IApplicationContext() {
38
39
			public void applicationRunning() {
40
			}
41
42
			public Map getArguments() {
43
				Map arguments = new HashMap();
44
45
				arguments.put(IApplicationContext.APPLICATION_ARGS, args);
46
47
				return arguments;
48
			}
49
50
			public String getBrandingApplication() {
51
				return null;
52
			}
53
54
			public Bundle getBrandingBundle() {
55
				return null;
56
			}
57
58
			public String getBrandingDescription() {
59
				return null;
60
			}
61
62
			public String getBrandingId() {
63
				return null;
64
			}
65
66
			public String getBrandingName() {
67
				return null;
68
			}
69
70
			public String getBrandingProperty(String key) {
71
				return null;
72
			}
73
		});
74
	}
75
76
	public void execute() {
77
		//create arguments
78
		String[] args = new String[] {"-source", source.toExternalForm(), "-destination", destination.toExternalForm(), "-writeMode", writeMode == null ? "" : writeMode};
79
80
		try {
81
			runMirrorApplication(message, args);
82
		} catch (Exception e) {
83
			throw new BuildException("Exception while running mirror application.", e);
84
		}
85
	}
86
87
	public void setSource(String value) throws MalformedURLException {
88
		source = new URL(value);
89
	}
90
91
	public void setDestination(String value) throws MalformedURLException {
92
		destination = new URL(value);
93
	}
94
95
	public void setMessage(String value) {
96
		message = value;
97
	}
98
99
	public void setWriteMode(String value) {
100
		writeMode = value;
101
	}
102
}

Return to bug 255913