Skip to main content
aboutsummaryrefslogblamecommitdiffstats
blob: 7639262453390b3880409f00ed030871874b6247 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                                                                 

                   








                                                                                     


                                             
 





                                                                                                         

















                                                                         


                                                                                                                                                                         




                                                                                          
                                                                                          

         





                                                                                                                                                            



                                                    
 
/*******************************************************************************
 * 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 options) {
		baseFilter = super.createFileFilter(options);
		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 options) {
		if (signArguments.get(JarProcessorTask.UNSIGN) != null)
			processor.addProcessStep(new UnsignCommand(properties, options.signCommand, options.verbose));
		if (signArguments.get(JarProcessorTask.SIGN) != null)
			processor.addProcessStep(new AntSignCommand(properties, signArguments, project, antTaskName, options.signCommand, options.verbose));
	}

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

Back to the top