Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 959c74eab498be0884f4e70ea1bc8e6b8ca4fd38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*******************************************************************************
 * Copyright (c) 2007, 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 - Initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.internal.p2.jarprocessor.ant;

import java.io.*;
import java.util.*;
import org.apache.tools.ant.Project;
import org.eclipse.equinox.internal.p2.jarprocessor.unsigner.UnsignCommand;
import org.eclipse.internal.provisional.equinox.p2.jarprocessor.JarProcessor;
import org.eclipse.internal.provisional.equinox.p2.jarprocessor.JarProcessorExecutor;

public class AntBasedProcessorExecutor extends JarProcessorExecutor {
	private final Project project;
	private final Properties signArguments;
	private final String antTaskName;
	private List inputFiles;
	private HashSet filterSet = null;
	private FileFilter baseFilter = null;

	public AntBasedProcessorExecutor(Properties signArguments, Project project, String antTaskName) {
		this.signArguments = signArguments;
		this.project = project;
		this.antTaskName = antTaskName;
	}

	protected FileFilter createFileFilter(Options opt) {
		baseFilter = super.createFileFilter(opt);
		if (inputFiles == null || inputFiles.size() == 0)
			return baseFilter;

		filterSet = new HashSet();
		filterSet.addAll(inputFiles);
		return new FileFilter() {
			public boolean accept(File pathname) {
				return getFilterSet().contains(pathname);
			}
		};
	}

	protected HashSet getFilterSet() {
		return filterSet;
	}

	protected void processDirectory(File input, FileFilter filter, boolean verbose, JarProcessor processor, Properties packProperties) throws FileNotFoundException {
		if (filterSet != null && filterSet.contains(input)) {
			File[] files = input.listFiles();
			for (int i = 0; i < files.length; i++) {
				if (files[i].isDirectory() || baseFilter.accept(files[i]))
					filterSet.add(files[i]);
			}
		}
		super.processDirectory(input, filter, verbose, processor, packProperties);
	}

	public void addSignStep(JarProcessor processor, Properties properties, Options opt) {
		if (signArguments.get(JarProcessorTask.UNSIGN) != null)
			processor.addProcessStep(new UnsignCommand(properties, opt.signCommand, opt.verbose));
		if (signArguments.get(JarProcessorTask.SIGN) != null)
			processor.addProcessStep(new AntSignCommand(properties, signArguments, project, antTaskName, opt.signCommand, opt.verbose));
	}

	public void setInputFiles(List inputFiles) {
		this.inputFiles = inputFiles;
	}
}

Back to the top