Skip to content

Commit aa0f881

Browse files
committed
Update all file paths to be relative.
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
1 parent 34387ac commit aa0f881

File tree

387 files changed

+45361
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

387 files changed

+45361
-113
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 58 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Java Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v1.*.*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
15+
env:
16+
JAVA_HOME: ${{ github.workspace }}/graalvm-ce-java11-22.3.3
17+
18+
steps:
19+
- name: Check out code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up JDK 11 from GraalVM
23+
run: |
24+
echo "${{ env.JAVA_HOME }}/bin" >> $GITHUB_PATH
25+
wget https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.3/graalvm-ce-java11-linux-amd64-22.3.3.tar.gz
26+
tar -xvzf graalvm-ce-java11-linux-amd64-22.3.3.tar.gz
27+
${{ env.JAVA_HOME }}/bin/gu install native-image
28+
29+
- name: Make gradlew executable
30+
run: chmod +x ./gradlew
31+
32+
- name: Build and Test
33+
id: build
34+
continue-on-error: true # Allow the workflow to continue if this fails
35+
run: ./gradlew clean fatJar
36+
37+
- name: Delete tag on failure
38+
if: steps.build.outcome != 'success'
39+
run: |
40+
git push --delete origin ${GITHUB_REF#refs/tags/}
41+
exit 1 # Fail the workflow
42+
43+
- name: Build Changelog
44+
id: gen_changelog
45+
uses: mikepenz/release-changelog-builder-action@v5
46+
with:
47+
failOnError: "true"
48+
configuration: .github/workflows/release_config.json
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Publish Release
53+
uses: softprops/action-gh-release@v1
54+
with:
55+
files: build/libs/*.jar
56+
body: ${{ steps.gen_changelog.outputs.changelog }}
57+
prerelease: true
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release_config.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"categories": [
3+
{
4+
"title": "## 🚀 Features",
5+
"labels": ["kind/feature", "enhancement"]
6+
},
7+
{
8+
"title": "## 🐛 Fixes",
9+
"labels": ["fix", "bug"]
10+
},
11+
{
12+
"title": "## ♻️ Refactoring",
13+
"labels": ["refactoring"]
14+
},
15+
{
16+
"title": "## ⚡️ Performance Improvements",
17+
"labels": ["performance"]
18+
},
19+
{
20+
"title": "## \uD83D\uDCDA Documentation",
21+
"labels": ["documentation", "doc"]
22+
},
23+
{
24+
"title": "## \uD83D\uDEA6 Tests",
25+
"labels": ["test"]
26+
},
27+
{
28+
"title": "## \uD83D\uDEE0 Other Updates",
29+
"labels": ["other", "kind/dependency-change"]
30+
}
31+
],
32+
"ignore_labels": [
33+
"ignore"
34+
]
35+
}

src/main/java/com/ibm/cldk/utils/BuildProject.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static String getGradleCommand() {
4646
String gradleSystemCommand = Arrays.stream(System.getenv("PATH").split(System.getProperty("path.separator"))).map(path -> new File(path, System.getProperty("os.name").toLowerCase().contains("windows") ? "gradle.bat" : "gradle")).filter(File::exists).findFirst().map(File::getAbsolutePath).orElse(null);
4747
File gradleWrapper = System.getProperty("os.name").toLowerCase().contains("windows") ? new File(projectRootPom, "gradlew.bat") : new File(projectRootPom, "gradlew");
4848

49-
return commandExists(gradleWrapper.getAbsoluteFile()).getKey() ? gradleWrapper.getAbsoluteFile().toString() : gradleSystemCommand;
49+
return commandExists(gradleWrapper.getAbsoluteFile()).getKey() ? gradleWrapper.getAbsoluteFile() .toString() : gradleSystemCommand;
5050
}
5151

5252
public static Path tempInitScript;
@@ -159,13 +159,13 @@ public static boolean gradleBuild(String projectPath) {
159159
}
160160

161161
private static boolean buildProject(String projectPath, String build) {
162-
File pomFile = new File(projectPath, "pom.xml");
162+
File pomFile = new File(String.valueOf(Paths.get(projectPath).toAbsolutePath()), "pom.xml");
163163
if (build == null) {
164164
return true;
165165
} else if (build.equals("auto")) {
166166
if (pomFile.exists()) {
167167
Log.info("Found pom.xml in the project directory. Using Maven to build the project.");
168-
return mavenBuild(projectPath); // Use Maven if pom.xml exists
168+
return mavenBuild(Paths.get(projectPath).toAbsolutePath().toString()); // Use Maven if pom.xml exists
169169
} else {
170170
Log.info("Did not find a pom.xml in the project directory. Using Gradle to build the project.");
171171
return gradleBuild(projectPath); // Otherwise, use Gradle
@@ -204,14 +204,14 @@ private static boolean mkLibDepDirs(String projectPath) {
204204
* Downloads library dependency jars of the given project so that the jars can be used
205205
* for type resolution during symbol table creation.
206206
*
207-
* @param projectPath Path to the project under analysis
207+
* @param projectPath Path to the project under javaee
208208
* @return true if dependency download succeeds; false otherwise
209209
*/
210210
public static boolean downloadLibraryDependencies(String projectPath, String projectRootPom) throws IOException {
211211
// created download dir if it does not exist
212212
String projectRoot = projectRootPom != null ? projectRootPom : projectPath;
213213

214-
File pomFile = new File(projectRoot, "pom.xml");
214+
File pomFile = new File((new File(projectRoot)).getAbsoluteFile(), "pom.xml");
215215
if (pomFile.exists()) {
216216
libDownloadPath = Paths.get(projectPath, "target", LIB_DEPS_DOWNLOAD_DIR).toAbsolutePath();
217217
if (mkLibDepDirs(projectPath))
@@ -231,21 +231,21 @@ public static boolean downloadLibraryDependencies(String projectPath, String pro
231231
));
232232
}
233233
Log.info("Found pom.xml in the project directory. Using Maven to download dependencies.");
234-
String[] mavenCommand = {MAVEN_CMD, "--no-transfer-progress", "-f", Paths.get(projectRoot, "pom.xml").toString(), "dependency:copy-dependencies", "-DoutputDirectory=" + libDownloadPath.toString()};
234+
String[] mavenCommand = {MAVEN_CMD, "--no-transfer-progress", "-f", Paths.get(projectRoot, "pom.xml").toAbsolutePath().toString(), "dependency:copy-dependencies", "-DoutputDirectory=" + libDownloadPath.toString()};
235235
return buildWithTool(mavenCommand);
236236
} else if (new File(projectRoot, "build.gradle").exists() || new File(projectRoot, "build.gradle.kts").exists()) {
237-
if (GRADLE_CMD == null || !commandExists(new File(GRADLE_CMD)).getKey()) {
238-
libDownloadPath = Paths.get(projectPath, "build", LIB_DEPS_DOWNLOAD_DIR).toAbsolutePath();
239-
if (mkLibDepDirs(projectPath))
240-
Log.debug("Dependencies found/created in " + libDownloadPath);
241-
else
242-
throw new IllegalStateException("Error creating library dependency directory in " + libDownloadPath);
237+
libDownloadPath = Paths.get(projectPath, "build", LIB_DEPS_DOWNLOAD_DIR).toAbsolutePath();
238+
if (mkLibDepDirs(projectPath))
239+
Log.debug("Dependencies found/created in " + libDownloadPath);
240+
else
241+
throw new IllegalStateException("Error creating library dependency directory in " + libDownloadPath);
243242

243+
if (GRADLE_CMD == null || !commandExists(new File(GRADLE_CMD)).getKey()) {
244244
String msg = GRADLE_CMD == null ?
245245
"Could not find Gradle or valid Gradle Wrapper" :
246246
MessageFormat.format("Could not verify that {0} exists", GRADLE_CMD);
247247
Log.error(msg);
248-
throw new IllegalStateException("Unable to execute Maven command. " +
248+
throw new IllegalStateException("Unable to execute Gradle command. " +
249249
(GRADLE_CMD == null ?
250250
"Could not find Gradle or valid Gradle Wrapper" :
251251
"Attempt failed with message\n" + commandExists(new File(GRADLE_CMD)).getValue()
@@ -271,8 +271,10 @@ public static void cleanLibraryDependencies() {
271271
if (libDownloadPath != null) {
272272
Log.info("Cleaning up library dependency directory: " + libDownloadPath);
273273
try {
274-
Files.walk(libDownloadPath).filter(Files::isRegularFile).map(Path::toFile).forEach(File::delete);
275-
Files.delete(libDownloadPath);
274+
if (libDownloadPath.toFile().getAbsoluteFile().exists()) {
275+
Files.walk(libDownloadPath).filter(Files::isRegularFile).map(Path::toFile).forEach(File::delete);
276+
Files.delete(libDownloadPath);
277+
}
276278
} catch (IOException e) {
277279
Log.warn("Unable to fully delete library dependency directory: " + e.getMessage());
278280
}
@@ -285,4 +287,4 @@ public static void cleanLibraryDependencies() {
285287
}
286288
}
287289
}
288-
}
290+
}

src/main/java/com/ibm/cldk/utils/ProjectDirectoryScanner.java

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@
77
import java.util.List;
88
import java.util.stream.Collectors;
99
import java.util.stream.Stream;
10-
import java.util.zip.ZipEntry;
11-
import java.util.zip.ZipFile;
1210

1311
public class ProjectDirectoryScanner {
1412
public static List<Path> classFilesStream(String projectPath) throws IOException {
15-
Path projectDir = Paths.get(projectPath);
13+
Path projectDir = Paths.get(projectPath).toAbsolutePath();
1614
Log.info("Finding *.class files in " + projectDir);
1715
if (Files.exists(projectDir)) {
1816
try (Stream<Path> paths = Files.walk(projectDir)) {
19-
return paths
20-
.filter(file -> !Files.isDirectory(file) && file.toString().endsWith(".class"))
21-
.filter(file -> !file.toAbsolutePath().toString().contains("test/resources/"))
22-
.filter(file -> !file.toAbsolutePath().toString().contains("main/resources/"))
17+
return paths.filter(file -> !Files.isDirectory(file) && file.toString().endsWith(".class"))
18+
.filter(file -> {
19+
// Let's find the path relative to the project directory
20+
Path relativePath = projectDir.relativize(file.toAbsolutePath());
21+
String relativePathAsString = relativePath.toString().replace("\\", "/"); // Windows fix
22+
return !relativePathAsString.contains("test/resources/") && !relativePathAsString.contains("main/resources/");
23+
})
2324
.collect(Collectors.toList());
2425
}
2526
}
@@ -39,46 +40,22 @@ public static List<Path> jarFilesStream(String projectPath) throws IOException {
3940
return null;
4041
}
4142

42-
/**
43-
* Returns a stream of class files inside the jars and class files in the project.
44-
* @param projectPath
45-
* @return
46-
* @throws IOException
47-
*/
48-
public static Stream<String> classesFromJarFileStream(String projectPath) throws IOException {
49-
List<Path> jarPaths = jarFilesStream(projectPath);
50-
51-
if (jarPaths == null) {
52-
return Stream.empty();
53-
}
54-
55-
return jarPaths.stream().flatMap(jarPath -> {
56-
try (ZipFile zip = new ZipFile(jarPath.toFile())) {
57-
return zip.stream()
58-
.filter(entry -> !entry.isDirectory() && entry.getName().endsWith(".class"))
59-
.map(ZipEntry::getName);
60-
} catch (IOException e) {
61-
return Stream.empty();
62-
}
63-
});
64-
}
65-
6643
public static List<Path> sourceFilesStream(String projectPath) throws IOException {
6744
Path projectDir = Paths.get(projectPath);
6845
Log.info("Finding *.java files in " + projectDir);
6946
if (Files.exists(projectDir)) {
7047
try (Stream<Path> paths = Files.walk(projectDir)) {
7148
return paths
72-
.filter(file -> !Files.isDirectory(file))
73-
.filter(file -> file.toString().endsWith(".java"))
74-
.filter(file -> !file.toAbsolutePath().toString().contains("build/"))
75-
.filter(file -> !file.toAbsolutePath().toString().contains("target/"))
76-
.filter(file -> !file.toAbsolutePath().toString().contains("main/resources/"))
77-
.filter(file -> !file.toAbsolutePath().toString().contains("test/resources/"))
78-
.collect(Collectors.toList());
49+
.filter(file -> !Files.isDirectory(file))
50+
.filter(file -> file.toString().endsWith(".java"))
51+
.filter(file -> !file.toAbsolutePath().toString().contains("build/"))
52+
.filter(file -> !file.toAbsolutePath().toString().contains("target/"))
53+
.filter(file -> !file.toAbsolutePath().toString().contains("main/resources/"))
54+
.filter(file -> !file.toAbsolutePath().toString().contains("test/resources/"))
55+
.collect(Collectors.toList());
7956
}
8057
}
8158
return null;
8259
}
8360

84-
}
61+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM open-liberty:full
2+
3+
COPY --chown=1001:0 src/main/liberty/config/server.xml /config/server.xml
4+
COPY --chown=1001:0 src/main/liberty/config/bootstrap.properties /config/bootstrap.properties
5+
COPY --chown=1001:0 target/io.openliberty.sample.daytrader8.war /config/apps/
6+
7+
#Derby
8+
COPY --chown=1001:0 target/liberty/wlp/usr/shared/resources/DerbyLibs/derby-10.14.2.0.jar /opt/ol/wlp/usr/shared/resources/DerbyLibs/derby-10.14.2.0.jar
9+
COPY --chown=1001:0 target/liberty/wlp/usr/shared/resources/data /opt/ol/wlp/usr/shared/resources/data
10+
11+
ENV MAX_USERS=1000
12+
ENV MAX_QUOTES=500
13+
14+
#RUN configure.sh
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Create folder db2jars/ and copy db2jcc4.jar and db2jcc_license_cu.jar to it.
2+
# Set Env below
3+
4+
FROM open-liberty:full
5+
6+
COPY --chown=1001:0 src/main/liberty/config/server.xml_db2 /config/server.xml
7+
COPY --chown=1001:0 src/main/liberty/config/bootstrap.properties /config/bootstrap.properties
8+
COPY --chown=1001:0 target/io.openliberty.sample.daytrader8.war /config/apps/
9+
10+
# DB2 JARS
11+
COPY --chown=1001:0 /db2jars /opt/ol/wlp/usr/shared/resources/db2jars
12+
13+
ENV contextRoot=daytrader
14+
ENV dbUser=
15+
ENV dbPass=
16+
ENV tradeDbHost=
17+
ENV tradeDbPort=
18+
ENV tradeDbName=
19+
20+
21+
#RUN configure.sh

0 commit comments

Comments
 (0)