|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2005 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 - Initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.pde.internal.build; |
| 12 |
|
| 13 |
import java.util.HashMap; |
| 14 |
import java.util.Map; |
| 15 |
|
| 16 |
import org.eclipse.core.runtime.CoreException; |
| 17 |
|
| 18 |
public class SourceBuildScriptGenerator extends AbstractScriptGenerator { |
| 19 |
|
| 20 |
private final static String PROPERTY_CONFIG = "config"; //$NON-NLS-1$ |
| 21 |
private final static String PROPERTY_BASE_LOCATION = "baseLocation"; //$NON-NLS-1$ |
| 22 |
private final static String PROPERTY_BUILD_TEMP_FOLDER = "buildTempFolder"; //$NON-NLS-1$ |
| 23 |
private final static String TARGET_BUILD = "build"; //$NON-NLS-1$ |
| 24 |
private final static String TARGET_GENERATE = "generate"; //$NON-NLS-1$ |
| 25 |
private final static String TARGET_ASSEMBLE = "assemble"; //$NON-NLS-1$ |
| 26 |
private final static String PREFIX = "eclipse"; //$NON-NLS-1$ |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
private String type; |
| 31 |
private String id; |
| 32 |
private String buildId; |
| 33 |
|
| 34 |
/** |
| 35 |
* TODO: add javadocs |
| 36 |
* @throws CoreException |
| 37 |
*/ |
| 38 |
public void generate() throws CoreException { |
| 39 |
|
| 40 |
openScript(workingDirectory, id + "-" + DEFAULT_BUILD_SCRIPT_FILENAME); //$NON-NLS-1$ |
| 41 |
script.println(); |
| 42 |
script.printComment("\"" + PROPERTY_BASE_LOCATION + "\" must be set by the caller of this script"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 43 |
script.printProjectDeclaration("Build " + id, TARGET_MAIN, null); //$NON-NLS-1$ |
| 44 |
script.println(); |
| 45 |
|
| 46 |
//TODO add logic to make ant fail if baseLocation isn't set (use condition task) |
| 47 |
script.printTargetDeclaration(TARGET_INIT, null, null, null, null); |
| 48 |
//TODO only allow builds on config triplets that the feature supports |
| 49 |
script.printProperty(PROPERTY_CONFIG, getDefaultConfigInfos()); |
| 50 |
script.printProperty(PROPERTY_OS, "${osgi.os}"); //$NON-NLS-1$ |
| 51 |
script.printProperty(PROPERTY_WS, "${osgi.ws}"); //$NON-NLS-1$ |
| 52 |
script.printProperty(PROPERTY_ARCH, "${osgi.arch}"); //$NON-NLS-1$ |
| 53 |
script.printProperty(PROPERTY_BUILD_TEMP_FOLDER, getPropertyFormat(PROPERTY_BASEDIR) + "/results"); //$NON-NLS-1$ |
| 54 |
script.printProperty(PROPERTY_JAVAC_FAIL_ON_ERROR, TRUE); |
| 55 |
script.printProperty(PROPERTY_JAVAC_VERBOSE, FALSE); |
| 56 |
script.printTargetEnd(); |
| 57 |
script.println(); |
| 58 |
|
| 59 |
script.printTargetDeclaration(TARGET_MAIN, TARGET_INIT, null, null, null); |
| 60 |
script.printAntCallTask(TARGET_GENERATE, null, null); |
| 61 |
script.printAntCallTask(TARGET_BUILD, null, null); |
| 62 |
script.printAntCallTask(TARGET_ASSEMBLE, null, null); |
| 63 |
script.printTargetEnd(); |
| 64 |
script.println(); |
| 65 |
|
| 66 |
script.printTargetDeclaration(TARGET_GENERATE, null, null, null, null); |
| 67 |
script.printBuildScriptTask(type + '@' + id, PREFIX, getPropertyFormat(PROPERTY_CONFIG), getPropertyFormat(PROPERTY_BASE_LOCATION), true); //$NON-NLS-1$ |
| 68 |
script.printTargetEnd(); |
| 69 |
script.println(); |
| 70 |
|
| 71 |
script.printTargetDeclaration(TARGET_BUILD, null, null, null, null); |
| 72 |
script.printAnt(DEFAULT_BUILD_SCRIPT_FILENAME, PREFIX + '/' + type + "s/" + id, TARGET_BUILD_JARS, null, null); //$NON-NLS-1$ |
| 73 |
script.printTargetEnd(); |
| 74 |
script.println(); |
| 75 |
|
| 76 |
script.printTargetDeclaration(TARGET_ASSEMBLE, null, null, null, null); |
| 77 |
Map map = new HashMap(1, 1F); |
| 78 |
map.put("buildId", buildId); //$NON-NLS-1$ |
| 79 |
script.printAnt("assemble." + id + ".xml", PREFIX, null, null, map); //$NON-NLS-1$ //$NON-NLS-2$ |
| 80 |
script.printTargetEnd(); |
| 81 |
script.println(); |
| 82 |
|
| 83 |
script.printProjectEnd(); |
| 84 |
script.close(); |
| 85 |
} |
| 86 |
|
| 87 |
public void setType(String type) { |
| 88 |
this.type = type; |
| 89 |
} |
| 90 |
|
| 91 |
public void setId(String id) { |
| 92 |
this.id = id; |
| 93 |
} |
| 94 |
|
| 95 |
public void setBuildId(String buildId) { |
| 96 |
this.buildId = buildId; |
| 97 |
} |
| 98 |
} |