Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/sourcetools/com.ibm.jpp.preprocessor/com/ibm/jpp/om/BuilderExtension.java
6004 views
1
/*******************************************************************************
2
* Copyright (c) 1999, 2021 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* 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-exception
21
*******************************************************************************/
22
package com.ibm.jpp.om;
23
24
import java.io.File;
25
import java.io.FileInputStream;
26
import java.io.IOException;
27
import java.util.List;
28
import java.util.Map;
29
import java.util.Map.Entry;
30
import java.util.Properties;
31
32
/**
33
* Represents the generalization of a Preprocessor builder extension.
34
*/
35
public abstract class BuilderExtension {
36
37
public static void loadProperties(Map<String, String> propertyMap, File propertiesFile) throws IOException {
38
try (FileInputStream input = new FileInputStream(propertiesFile)) {
39
Properties properties = new Properties();
40
41
properties.load(input);
42
43
for (Entry<?, ?> entry : properties.entrySet()) {
44
propertyMap.put((String) entry.getKey(), (String) entry.getValue());
45
}
46
}
47
}
48
49
private final String name;
50
protected Builder builder;
51
52
protected BuilderExtension(String name) {
53
if (name == null) {
54
throw new NullPointerException();
55
}
56
this.name = name;
57
}
58
59
/**
60
* Returns this extension's name.
61
*
62
* @return the extension name
63
*/
64
public String getName() {
65
return this.name;
66
}
67
68
/**
69
* Sets this extension's builder
70
*
71
* @param builder the builder
72
*/
73
public void setBuilder(Builder builder) {
74
this.builder = builder;
75
}
76
77
/**
78
* Validates the build options.
79
*
80
* @param options the options to validate
81
*
82
* @throws BuilderConfigurationException
83
*/
84
public void validateOptions(Properties options) throws BuilderConfigurationException {
85
// nop
86
}
87
88
/**
89
* Determines if the source file should be built as part of the preprocess job.
90
*
91
* @param sourceFile the source file
92
* @param outputFile the destination for the preprocessed file
93
* @param relativePath the files' relative path
94
* @return <code>true</code> if the file should be built, <code>false</code> otherwise
95
*/
96
public boolean shouldBuild(File sourceFile, File outputFile, String relativePath) {
97
return true;
98
}
99
100
/*[PR 118220] Incremental builder is not called when file is deleted in base library*/
101
/**
102
* Determines if the source file should be deleted as part of the preprocess job.
103
*
104
* @param sourceDir the source directory
105
* @return returns vector of deleted files
106
*/
107
public List<String> getDeleteFiles(File sourceDir) {
108
return null;
109
}
110
111
/**
112
* gets changed resources from IcrementalFilterExtension
113
*
114
* @param sourceDir the source directory
115
* @return returns vector of changed resources
116
*/
117
/*[PR 119753] classes.txt and AutoRuns are not updated when new test class is added */
118
public List<String> getBuildResources(File sourceDir) {
119
return null;
120
}
121
122
/**
123
* Notifies listeners that the preprocess job has begun.
124
*/
125
public void notifyBuildBegin() {
126
// nop
127
}
128
129
/**
130
* Notifies listeners that the preprocess job has ended.
131
*/
132
public void notifyBuildEnd() {
133
// nop
134
}
135
136
/**
137
* Notifies listeners that sourceFile is being built.
138
*
139
* @param sourceFile the source file
140
* @param outputFile the destination for the preprocessed file
141
* @param relativePath the files' relative path
142
*/
143
public void notifyBuildFileBegin(File sourceFile, File outputFile, String relativePath) {
144
// nop
145
}
146
147
/**
148
* Notifies listeners that sourceFile has been built.
149
*
150
* @param sourceFile the source file
151
* @param outputFile the destination for the preprocessed file
152
* @param relativePath the files' relative path
153
*/
154
public void notifyBuildFileEnd(File sourceFile, File outputFile, String relativePath) {
155
// nop
156
}
157
158
/**
159
* Notifies that the preprocessor is being configured.
160
*
161
* @param preprocessor the preprocessor to be used
162
*/
163
public void notifyConfigurePreprocessor(JavaPreprocessor preprocessor) {
164
// nop
165
}
166
167
}
168
169