Path: blob/master/sourcetools/com.ibm.jpp.preprocessor/com/ibm/jpp/om/BuilderExtension.java
6004 views
/*******************************************************************************1* Copyright (c) 1999, 2021 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/21package com.ibm.jpp.om;2223import java.io.File;24import java.io.FileInputStream;25import java.io.IOException;26import java.util.List;27import java.util.Map;28import java.util.Map.Entry;29import java.util.Properties;3031/**32* Represents the generalization of a Preprocessor builder extension.33*/34public abstract class BuilderExtension {3536public static void loadProperties(Map<String, String> propertyMap, File propertiesFile) throws IOException {37try (FileInputStream input = new FileInputStream(propertiesFile)) {38Properties properties = new Properties();3940properties.load(input);4142for (Entry<?, ?> entry : properties.entrySet()) {43propertyMap.put((String) entry.getKey(), (String) entry.getValue());44}45}46}4748private final String name;49protected Builder builder;5051protected BuilderExtension(String name) {52if (name == null) {53throw new NullPointerException();54}55this.name = name;56}5758/**59* Returns this extension's name.60*61* @return the extension name62*/63public String getName() {64return this.name;65}6667/**68* Sets this extension's builder69*70* @param builder the builder71*/72public void setBuilder(Builder builder) {73this.builder = builder;74}7576/**77* Validates the build options.78*79* @param options the options to validate80*81* @throws BuilderConfigurationException82*/83public void validateOptions(Properties options) throws BuilderConfigurationException {84// nop85}8687/**88* Determines if the source file should be built as part of the preprocess job.89*90* @param sourceFile the source file91* @param outputFile the destination for the preprocessed file92* @param relativePath the files' relative path93* @return <code>true</code> if the file should be built, <code>false</code> otherwise94*/95public boolean shouldBuild(File sourceFile, File outputFile, String relativePath) {96return true;97}9899/*[PR 118220] Incremental builder is not called when file is deleted in base library*/100/**101* Determines if the source file should be deleted as part of the preprocess job.102*103* @param sourceDir the source directory104* @return returns vector of deleted files105*/106public List<String> getDeleteFiles(File sourceDir) {107return null;108}109110/**111* gets changed resources from IcrementalFilterExtension112*113* @param sourceDir the source directory114* @return returns vector of changed resources115*/116/*[PR 119753] classes.txt and AutoRuns are not updated when new test class is added */117public List<String> getBuildResources(File sourceDir) {118return null;119}120121/**122* Notifies listeners that the preprocess job has begun.123*/124public void notifyBuildBegin() {125// nop126}127128/**129* Notifies listeners that the preprocess job has ended.130*/131public void notifyBuildEnd() {132// nop133}134135/**136* Notifies listeners that sourceFile is being built.137*138* @param sourceFile the source file139* @param outputFile the destination for the preprocessed file140* @param relativePath the files' relative path141*/142public void notifyBuildFileBegin(File sourceFile, File outputFile, String relativePath) {143// nop144}145146/**147* Notifies listeners that sourceFile has been built.148*149* @param sourceFile the source file150* @param outputFile the destination for the preprocessed file151* @param relativePath the files' relative path152*/153public void notifyBuildFileEnd(File sourceFile, File outputFile, String relativePath) {154// nop155}156157/**158* Notifies that the preprocessor is being configured.159*160* @param preprocessor the preprocessor to be used161*/162public void notifyConfigurePreprocessor(JavaPreprocessor preprocessor) {163// nop164}165166}167168169