Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# This workflow will build and test all Gradle-migrated projects in specs-java-libs every day at midnight
# It will also run on every push and pull request

name: nightly

on:
push:
workflow_dispatch:

permissions:
checks: write
contents: write

env:
JAVA_VERSION: 17

jobs:
build-gradle-projects:
name: Build & Test Gradle Projects Sequentially
runs-on: ubuntu-latest
steps:
- name: Checkout specs-java-libs
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: current
dependency-graph: generate-and-submit

- name: Build and test all Gradle projects sequentially
run: |
projects=(
AsmParser
CommonsCompressPlus
CommonsLangPlus
GearmanPlus
GitPlus
Gprofer
GsonPlus
GuiHelper
JacksonPlus
JadxPlus
JavaGenerator
jOptions
JsEngine
LogbackPlus
SpecsUtils
SymjaPlus
tdrcLibrary
XStreamPlus
)
failed=()
for project in "${projects[@]}"; do
echo "\n===== Building and testing $project ====="
cd "$project"
if ! gradle build test; then
echo "[ERROR] $project failed to build or test"
failed+=("$project")
fi
cd -
done
if [ ${#failed[@]} -ne 0 ]; then
echo "\nThe following projects failed: ${failed[*]}"
exit 1
fi
env:
GITHUB_DEPENDENCY_GRAPH_ENABLED: false

- name: Publish Test Reports
uses: mikepenz/action-junit-report@v4
if: always()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
summary: true
39 changes: 35 additions & 4 deletions CommonsCompressPlus/src/pt/up/fe/specs/compress/ZipFormat.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* Copyright 2017 SPeCS.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License. under the License.
* specific language governing permissions and limitations under the License.
*/

package pt.up.fe.specs.compress;
Expand All @@ -26,28 +26,59 @@
import pt.up.fe.specs.util.lazy.Lazy;
import pt.up.fe.specs.util.providers.StringProvider;

/**
* Enum representing supported compression formats for file output.
* <p>
* Provides methods to create compressors for ZIP and GZ formats and to retrieve formats by extension.
*/
public enum ZipFormat implements StringProvider {

/** ZIP file format. */
ZIP("zip"),
/** GZ (GZip) file format. */
GZ("gz");

private static final Lazy<EnumHelperWithValue<ZipFormat>> ENUM_HELPER = EnumHelperWithValue.newLazyHelperWithValue(ZipFormat.class);

private final String extension;

/**
* Creates a new ZipFormat with the given file extension.
*
* @param extension the file extension for the format
*/
private ZipFormat(String extension) {
this.extension = extension;
}

/**
* Returns an Optional containing the ZipFormat corresponding to the given extension, if available.
*
* @param extension the file extension
* @return an Optional with the matching ZipFormat, or empty if not found
*/
public static Optional<ZipFormat> fromExtension(String extension) {
return ENUM_HELPER.get().fromValueTry(extension);
}

/**
* Returns the string representation (file extension) of this format.
*
* @return the file extension
*/
@Override
public String getString() {
return extension;
}

/**
* Creates a new file compressor OutputStream for the given filename and output stream, according to this format.
*
* @param filename the name of the file to compress (used for ZIP entries)
* @param outputStream the output stream to wrap
* @return a new OutputStream for the compressed file
* @throws RuntimeException if the compressor cannot be created
*/
public OutputStream newFileCompressor(String filename, OutputStream outputStream) {
switch (this) {
case ZIP:
Expand Down
14 changes: 14 additions & 0 deletions CommonsLangPlus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# CommonsLangPlus

CommonsLangPlus is a utility library that provides additional wrappers and helpers around the Apache Commons Lang and Commons Text libraries. It offers platform detection utilities and string manipulation helpers to simplify common Java development tasks.

## Features
- Platform detection (Windows, Linux, Mac, Unix, ARM, CentOS)
- String escaping utilities (HTML, etc.)
- Lightweight and easy to use

## Usage
Add CommonsLangPlus to your Java project and use the static utility methods for platform checks and string operations.

## License
This project is licensed under the Apache License 2.0.
17 changes: 13 additions & 4 deletions CommonsLangPlus/src/pt/up/fe/specs/lang/ApacheStrings.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
/**
* Copyright 2017 SPeCS.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License. under the License.
* specific language governing permissions and limitations under the License.
*/

package pt.up.fe.specs.lang;

import org.apache.commons.text.StringEscapeUtils;

/**
* Utility class for Apache Commons Text string operations.
*/
public class ApacheStrings {

/**
* Escapes HTML entities in the given string using Apache Commons Text.
*
* @param html the input HTML string
* @return the escaped HTML string
*/
public static String escapeHtml(String html) {
return StringEscapeUtils.escapeHtml4(html);
}
Expand Down
62 changes: 30 additions & 32 deletions CommonsLangPlus/src/pt/up/fe/specs/lang/SpecsPlatforms.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,88 +8,86 @@
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License. under the License.
* specific language governing permissions and limitations under the License.
*/

package pt.up.fe.specs.lang;

import org.apache.commons.lang3.SystemUtils;

/**
* Wrappers around Apache commons-lang utility methods related to system platform identification.
*
* Utility class providing wrappers around Apache commons-lang methods for system platform identification.
* <p>
* Includes methods to check the current operating system and platform details.
*
* TODO: Rename to ApachePlatforms
*
* @author JoaoBispo
*
*/
public class SpecsPlatforms {

/**
* Returns true if the operating system is a form of Windows.
*
* @return true if Windows OS, false otherwise
*/
public static boolean isWindows() {
return SystemUtils.IS_OS_WINDOWS;
}

/**
* Returns true if the operating system is a form of Linux.
*
* @return true if Linux OS, false otherwise
*/
public static boolean isLinux() {
return SystemUtils.IS_OS_LINUX;
}

/**
* Returns true if the operating system is a form of Linux.
* Returns true if the operating system is Linux running on ARM architecture.
*
* @return true if Linux ARM, false otherwise
*/
public static boolean isLinuxArm() {
return SystemUtils.IS_OS_LINUX && "arm".equals(System.getProperty("os.arch").toLowerCase());
}

/**
* Returns true if the operating system version indicates CentOS 6.
*
* @return true if CentOS 6, false otherwise
*/
public static boolean isCentos6() {
return System.getProperty("os.version").contains(".el6.");
}

/**
* Returns the name of the current platform/OS.
*
* @return the OS name
*/
public static String getPlatformName() {
return SystemUtils.OS_NAME;
}

/**
* Returns true if the operating system is a form of Linux or Solaris.
* Returns true if the operating system is a form of Unix (Linux or Solaris).
*
* @return true if Unix OS, false otherwise
*/
public static boolean isUnix() {
return SystemUtils.IS_OS_UNIX;
}

/**
* Returns true if the operating system is a form of Mac OS.
*
* @return true if Mac OS, false otherwise
*/
public static boolean isMac() {
return SystemUtils.IS_OS_MAC;
}

/*
public static Process getShell() {
String cmd = getShellCommand();

ProcessBuilder builder = new ProcessBuilder(cmd);

try {
return builder.start();
} catch (IOException e) {
throw new RuntimeException("Could not start process " + cmd);
}
}

public static String getShellCommand() {
if (isWindows()) {
return "cmd.exe /start";
}

if (isUnix()) {
return "/bin/bash";
}

throw new RuntimeException("No shell defined for platform " + getPlatformName());
}
*/

// TODO: Implement shell-related utilities if needed in the future.
}
Loading
Loading