Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/sourcetools/com.ibm.uma/com/ibm/uma/om/Include.java
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2001, 2017 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.uma.om;
23
24
import com.ibm.uma.UMA;
25
import com.ibm.uma.UMAException;
26
import com.ibm.uma.util.Logger;
27
28
public class Include extends PredicateList {
29
30
public static final int TYPE_ROOT_PATH = 0;
31
public static final int TYPE_ARTIFACT = 1;
32
public static final int TYPE_MACRO = 2;
33
public static final int TYPE_RELATIVE_PATH = 3;
34
35
int type;
36
String path;
37
String macro;
38
39
40
public Include( String containingFile ) {
41
super(containingFile);
42
}
43
44
public void setPath(String path) {
45
this.path = path;
46
}
47
48
public void setType(String typeString ) {
49
if ( typeString.equalsIgnoreCase("rootpath") ) {
50
type = TYPE_ROOT_PATH;
51
} else if ( typeString.equalsIgnoreCase("relativepath") ) {
52
type = TYPE_RELATIVE_PATH;
53
} else if ( typeString.equalsIgnoreCase("artifact") ) {
54
type = TYPE_ARTIFACT;
55
} else if ( typeString.equalsIgnoreCase("macro") ) {
56
type = TYPE_MACRO;
57
}
58
}
59
60
public String getPath() {
61
return path;
62
}
63
64
public int getType() {
65
return type;
66
}
67
68
@Override
69
public boolean evaluate() throws UMAException {
70
if ( !super.evaluate() ) return false;
71
72
if ( type == TYPE_MACRO ) {
73
macro = path;
74
path = UMA.getUma().getPlatform().replaceMacro(path);
75
type = TYPE_ARTIFACT;
76
}
77
78
if ( type == TYPE_ARTIFACT ) {
79
Artifact artifact = UMA.getUma().getArtifact(path);
80
if ( artifact == null ) {
81
// TODO turn this into hard-error vs. soft-error
82
if ( macro != null ) {
83
Logger.getLogger().println(Logger.WarningLog, "Warning: include path macro " + macro + " does not expand to an artifact. [" + containingFile + "]");
84
} else {
85
Logger.getLogger().println(Logger.WarningLog, "Warning: include path " + path + " of type artifact not found. [" + containingFile + "]");
86
}
87
return false;
88
} else if ( artifact.evaluate() ) {
89
path = artifact.getContainingModule().getFullName();
90
type = TYPE_ROOT_PATH;
91
} else {
92
return false;
93
}
94
95
}
96
return true;
97
}
98
}
99
100
101