Skip to content

Commit

Permalink
Update all file paths to be relative.
Browse files Browse the repository at this point in the history
Signed-off-by: Rahul Krishna <[email protected]>
  • Loading branch information
rahlk committed Feb 12, 2025
1 parent 34387ac commit aa0f881
Show file tree
Hide file tree
Showing 387 changed files with 45,361 additions and 113 deletions.
58 changes: 0 additions & 58 deletions .github/workflows/main.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Java Release

on:
push:
tags:
- "v1.*.*"

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest

env:
JAVA_HOME: ${{ github.workspace }}/graalvm-ce-java11-22.3.3

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up JDK 11 from GraalVM
run: |
echo "${{ env.JAVA_HOME }}/bin" >> $GITHUB_PATH
wget https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.3/graalvm-ce-java11-linux-amd64-22.3.3.tar.gz
tar -xvzf graalvm-ce-java11-linux-amd64-22.3.3.tar.gz
${{ env.JAVA_HOME }}/bin/gu install native-image
- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Build and Test
id: build
continue-on-error: true # Allow the workflow to continue if this fails
run: ./gradlew clean fatJar

- name: Delete tag on failure
if: steps.build.outcome != 'success'
run: |
git push --delete origin ${GITHUB_REF#refs/tags/}
exit 1 # Fail the workflow
- name: Build Changelog
id: gen_changelog
uses: mikepenz/release-changelog-builder-action@v5
with:
failOnError: "true"
configuration: .github/workflows/release_config.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Release
uses: softprops/action-gh-release@v1
with:
files: build/libs/*.jar
body: ${{ steps.gen_changelog.outputs.changelog }}
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/release_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"categories": [
{
"title": "## 🚀 Features",
"labels": ["kind/feature", "enhancement"]
},
{
"title": "## 🐛 Fixes",
"labels": ["fix", "bug"]
},
{
"title": "## ♻️ Refactoring",
"labels": ["refactoring"]
},
{
"title": "## ⚡️ Performance Improvements",
"labels": ["performance"]
},
{
"title": "## \uD83D\uDCDA Documentation",
"labels": ["documentation", "doc"]
},
{
"title": "## \uD83D\uDEA6 Tests",
"labels": ["test"]
},
{
"title": "## \uD83D\uDEE0 Other Updates",
"labels": ["other", "kind/dependency-change"]
}
],
"ignore_labels": [
"ignore"
]
}
34 changes: 18 additions & 16 deletions src/main/java/com/ibm/cldk/utils/BuildProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static String getGradleCommand() {
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);
File gradleWrapper = System.getProperty("os.name").toLowerCase().contains("windows") ? new File(projectRootPom, "gradlew.bat") : new File(projectRootPom, "gradlew");

return commandExists(gradleWrapper.getAbsoluteFile()).getKey() ? gradleWrapper.getAbsoluteFile().toString() : gradleSystemCommand;
return commandExists(gradleWrapper.getAbsoluteFile()).getKey() ? gradleWrapper.getAbsoluteFile() .toString() : gradleSystemCommand;
}

public static Path tempInitScript;
Expand Down Expand Up @@ -159,13 +159,13 @@ public static boolean gradleBuild(String projectPath) {
}

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

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

if (GRADLE_CMD == null || !commandExists(new File(GRADLE_CMD)).getKey()) {
String msg = GRADLE_CMD == null ?
"Could not find Gradle or valid Gradle Wrapper" :
MessageFormat.format("Could not verify that {0} exists", GRADLE_CMD);
Log.error(msg);
throw new IllegalStateException("Unable to execute Maven command. " +
throw new IllegalStateException("Unable to execute Gradle command. " +
(GRADLE_CMD == null ?
"Could not find Gradle or valid Gradle Wrapper" :
"Attempt failed with message\n" + commandExists(new File(GRADLE_CMD)).getValue()
Expand All @@ -271,8 +271,10 @@ public static void cleanLibraryDependencies() {
if (libDownloadPath != null) {
Log.info("Cleaning up library dependency directory: " + libDownloadPath);
try {
Files.walk(libDownloadPath).filter(Files::isRegularFile).map(Path::toFile).forEach(File::delete);
Files.delete(libDownloadPath);
if (libDownloadPath.toFile().getAbsoluteFile().exists()) {
Files.walk(libDownloadPath).filter(Files::isRegularFile).map(Path::toFile).forEach(File::delete);
Files.delete(libDownloadPath);
}
} catch (IOException e) {
Log.warn("Unable to fully delete library dependency directory: " + e.getMessage());
}
Expand All @@ -285,4 +287,4 @@ public static void cleanLibraryDependencies() {
}
}
}
}
}
55 changes: 16 additions & 39 deletions src/main/java/com/ibm/cldk/utils/ProjectDirectoryScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class ProjectDirectoryScanner {
public static List<Path> classFilesStream(String projectPath) throws IOException {
Path projectDir = Paths.get(projectPath);
Path projectDir = Paths.get(projectPath).toAbsolutePath();
Log.info("Finding *.class files in " + projectDir);
if (Files.exists(projectDir)) {
try (Stream<Path> paths = Files.walk(projectDir)) {
return paths
.filter(file -> !Files.isDirectory(file) && file.toString().endsWith(".class"))
.filter(file -> !file.toAbsolutePath().toString().contains("test/resources/"))
.filter(file -> !file.toAbsolutePath().toString().contains("main/resources/"))
return paths.filter(file -> !Files.isDirectory(file) && file.toString().endsWith(".class"))
.filter(file -> {
// Let's find the path relative to the project directory
Path relativePath = projectDir.relativize(file.toAbsolutePath());
String relativePathAsString = relativePath.toString().replace("\\", "/"); // Windows fix
return !relativePathAsString.contains("test/resources/") && !relativePathAsString.contains("main/resources/");
})
.collect(Collectors.toList());
}
}
Expand All @@ -39,46 +40,22 @@ public static List<Path> jarFilesStream(String projectPath) throws IOException {
return null;
}

/**
* Returns a stream of class files inside the jars and class files in the project.
* @param projectPath
* @return
* @throws IOException
*/
public static Stream<String> classesFromJarFileStream(String projectPath) throws IOException {
List<Path> jarPaths = jarFilesStream(projectPath);

if (jarPaths == null) {
return Stream.empty();
}

return jarPaths.stream().flatMap(jarPath -> {
try (ZipFile zip = new ZipFile(jarPath.toFile())) {
return zip.stream()
.filter(entry -> !entry.isDirectory() && entry.getName().endsWith(".class"))
.map(ZipEntry::getName);
} catch (IOException e) {
return Stream.empty();
}
});
}

public static List<Path> sourceFilesStream(String projectPath) throws IOException {
Path projectDir = Paths.get(projectPath);
Log.info("Finding *.java files in " + projectDir);
if (Files.exists(projectDir)) {
try (Stream<Path> paths = Files.walk(projectDir)) {
return paths
.filter(file -> !Files.isDirectory(file))
.filter(file -> file.toString().endsWith(".java"))
.filter(file -> !file.toAbsolutePath().toString().contains("build/"))
.filter(file -> !file.toAbsolutePath().toString().contains("target/"))
.filter(file -> !file.toAbsolutePath().toString().contains("main/resources/"))
.filter(file -> !file.toAbsolutePath().toString().contains("test/resources/"))
.collect(Collectors.toList());
.filter(file -> !Files.isDirectory(file))
.filter(file -> file.toString().endsWith(".java"))
.filter(file -> !file.toAbsolutePath().toString().contains("build/"))
.filter(file -> !file.toAbsolutePath().toString().contains("target/"))
.filter(file -> !file.toAbsolutePath().toString().contains("main/resources/"))
.filter(file -> !file.toAbsolutePath().toString().contains("test/resources/"))
.collect(Collectors.toList());
}
}
return null;
}

}
}
14 changes: 14 additions & 0 deletions src/test/resources/test-applications/daytrader8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM open-liberty:full

COPY --chown=1001:0 src/main/liberty/config/server.xml /config/server.xml
COPY --chown=1001:0 src/main/liberty/config/bootstrap.properties /config/bootstrap.properties
COPY --chown=1001:0 target/io.openliberty.sample.daytrader8.war /config/apps/

#Derby
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
COPY --chown=1001:0 target/liberty/wlp/usr/shared/resources/data /opt/ol/wlp/usr/shared/resources/data

ENV MAX_USERS=1000
ENV MAX_QUOTES=500

#RUN configure.sh
21 changes: 21 additions & 0 deletions src/test/resources/test-applications/daytrader8/Dockerfile-db2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Create folder db2jars/ and copy db2jcc4.jar and db2jcc_license_cu.jar to it.
# Set Env below

FROM open-liberty:full

COPY --chown=1001:0 src/main/liberty/config/server.xml_db2 /config/server.xml
COPY --chown=1001:0 src/main/liberty/config/bootstrap.properties /config/bootstrap.properties
COPY --chown=1001:0 target/io.openliberty.sample.daytrader8.war /config/apps/

# DB2 JARS
COPY --chown=1001:0 /db2jars /opt/ol/wlp/usr/shared/resources/db2jars

ENV contextRoot=daytrader
ENV dbUser=
ENV dbPass=
ENV tradeDbHost=
ENV tradeDbPort=
ENV tradeDbName=


#RUN configure.sh
Loading

0 comments on commit aa0f881

Please sign in to comment.