Skip to content
Merged
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
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
java_version: ['11', '17', '21']
java_version: ['17', '21', '25']
fail-fast: false

steps:
Expand All @@ -41,7 +41,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
java_version: ['17', '21']
java_version: ['17', '21', '25']
fail-fast: false

steps:
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
java_version: ['11', '17', '21']
java_version: ['17', '21', '25']
fail-fast: false

steps:
Expand Down Expand Up @@ -174,11 +174,11 @@ jobs:
check-latest: true
go-version-file: 'go.mod'

- name: Build distro for ${{ matrix.os }}
- name: Build distro
run: go run build/make.go --all-platforms && go run build/make.go --all-platforms --distro
shell: bash

- name: Upload artifacts for ${{ matrix.os }}
- name: Upload artifacts
uses: actions/upload-artifact@v5
with:
name: gauge-java-artifacts
Expand Down
5 changes: 5 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="FileTabCharacter"/>

<module name="SuppressWithPlainTextCommentFilter">
<property name="offCommentFormat" value='=\s+"""'/>
<property name="onCommentFormat" value='^\s+.*""";'/>
</module>

<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="RegexpSingleline">
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/getgauge/gauge-java

go 1.24
go 1.25
2 changes: 1 addition & 1 deletion java.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "java",
"version": "0.13.0",
"version": "1.0.0",
"description": "Java support for gauge",
"install": {
"windows": [],
Expand Down
17 changes: 9 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<name>gauge-java</name>
<groupId>com.thoughtworks.gauge</groupId>
<artifactId>gauge-java</artifactId>
<version>0.13.0</version>
<version>1.0.0</version>
<description>Java plugin for Gauge</description>
<url>https://github.com/getgauge/gauge-java</url>
<dependencyManagement>
Expand All @@ -19,7 +19,7 @@
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.14.0</version>
<version>6.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -46,7 +46,7 @@
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.27.0</version>
<version>3.27.1</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
Expand Down Expand Up @@ -235,7 +235,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.26.1</version>
<version>12.1.1</version>
</dependency>
</dependencies>
<executions>
Expand All @@ -262,7 +262,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.8.1</version>
<version>3.9.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
Expand Down Expand Up @@ -312,12 +312,13 @@
<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.release>${java.version}</maven.compiler.release>

<protobuf.version>4.32.1</protobuf.version>
<grpc.version>1.75.0</grpc.version>
<protobuf.version>4.33.0</protobuf.version>
<grpc.version>1.76.0</grpc.version>
</properties>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class DefaultClassInitializer implements ClassInitializer {

@Override
public Object initialize(Class<?> classToInitialize) throws Exception {
return Class.forName(classToInitialize.getName()).newInstance();
return Class.forName(classToInitialize.getName()).getDeclaredConstructor().newInstance();
}
}
9 changes: 4 additions & 5 deletions src/main/java/com/thoughtworks/gauge/FileHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand All @@ -28,7 +27,7 @@ public class FileHelper {
public static List<String> getAllImplementationFiles() {
ArrayList<String> outputFiles = new ArrayList<>();
getStepImplDirs().forEach(dir -> {
try (Stream<Path> filePathStream = Files.walk(Paths.get(dir))) {
try (Stream<Path> filePathStream = Files.walk(Path.of(dir))) {
filePathStream.forEach(filePath -> {
if (Files.isRegularFile(filePath) && filePath.toString().endsWith(JAVA_FILE_EXT)) {
outputFiles.add(filePath.toString());
Expand All @@ -42,8 +41,8 @@ public static List<String> getAllImplementationFiles() {
}

private static Path getAbsolutePath(String dir) {
Path path = Paths.get(dir);
return !path.isAbsolute() ? Paths.get(System.getenv(GAUGE_PROJECT_ROOT), dir) : path;
Path path = Path.of(dir);
return !path.isAbsolute() ? Path.of(System.getenv(GAUGE_PROJECT_ROOT), dir) : path;
}

static List<String> getStepImplDirs() {
Expand All @@ -65,7 +64,7 @@ public static String getClassName(File filepath) {

public static File getDefaultImplFileName(String suffix, int count) {
String filename = "StepImplementation" + suffix + JAVA_FILE_EXT;
Path filepath = Paths.get(getDefaultStepImplDir(), filename);
Path filepath = Path.of(getDefaultStepImplDir(), filename);
File file = new File(filepath.toString());
return file.exists() ? getDefaultImplFileName(String.valueOf(++count), count) : file;
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/thoughtworks/gauge/StepValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ public boolean equals(Object o) {
return true;
}

if (!(o instanceof StepValue)) {
if (!(o instanceof StepValue stepValue)) {
return false;
}

StepValue stepValue = (StepValue) o;
return Objects.equals(parameterizedStepText, stepValue.parameterizedStepText)
&& Objects.equals(parameters, stepValue.parameters)
&& Objects.equals(stepText, stepValue.stepText);
Expand Down
13 changes: 4 additions & 9 deletions src/main/java/com/thoughtworks/gauge/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,16 @@ private int getMaxStringSize(List<String> candidates) {
}

private Comparator<String> maxStringLength() {
return (o1, o2) -> {
if (o1.length() < o2.length()) {
return -1;
}
return 1;
};
return Comparator.comparingInt(String::length);
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((headers == null) ? 0 : headers.hashCode());
result = prime * result + ((rows == null) ? 0 : rows.hashCode());
result = prime * result + ((tableRows == null) ? 0 : tableRows.hashCode());
result = prime * result + (headers == null ? 0 : headers.hashCode());
result = prime * result + (rows == null ? 0 : rows.hashCode());
result = prime * result + (tableRows == null ? 0 : tableRows.hashCode());
return result;
}

Expand Down
35 changes: 24 additions & 11 deletions src/main/java/com/thoughtworks/gauge/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
*----------------------------------------------------------------*/
package com.thoughtworks.gauge;

import com.google.common.base.Splitter;

import java.io.File;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Util {
private static final Splitter SPACE_SPLITTER = Splitter.on(" ").trimResults().omitEmptyStrings();

public static File workingDir() {
String wd = System.getenv(GaugeConstant.GAUGE_PROJECT_ROOT);
if (wd != null && !wd.isEmpty()) {
Expand All @@ -17,15 +24,13 @@ public static File workingDir() {
}

public static String convertToCamelCase(String s) {
String[] words = s.trim().split(" ");
String text = words[0].toLowerCase();
for (int i = 1, wordsLength = words.length; i < wordsLength; i++) {
String word = words[i].trim();
if (!word.isEmpty()) {
text += words[i].substring(0, 1).toUpperCase() + words[i].substring(1).toLowerCase();
}
}
return text;
List<String> words = SPACE_SPLITTER.splitToList(s);
return IntStream.range(0, words.size())
.mapToObj(i -> {
String word = words.get(i);
return i == 0 ? word.toLowerCase() : Character.toUpperCase(word.charAt(0)) + word.substring(1).toLowerCase();
})
.collect(Collectors.joining());
}

public static String getValidJavaIdentifier(String s) {
Expand All @@ -39,12 +44,20 @@ public static String getValidJavaIdentifier(String s) {
}

public static String trimQuotes(String text) {
return text == null ? null : text.replaceFirst("^\"", "").replaceFirst("\"$", "");
if (text == null || text.isBlank()) {
return text;
}
int start = text.charAt(0) == '"' ? 1 : 0;
int end = text.length();
if (end > start && text.charAt(end - 1) == '"') {
end--;
}
return text.substring(start, end);
}

public static boolean shouldTakeFailureScreenshot() {
String screenshotOnFailureEnabled = System.getenv(GaugeConstant.SCREENSHOT_ON_FAILURE_ENABLED);
return !(screenshotOnFailureEnabled == null || screenshotOnFailureEnabled.equalsIgnoreCase("false"));
return !(screenshotOnFailureEnabled == null || "false".equalsIgnoreCase(screenshotOnFailureEnabled));
}

}
Loading
Loading