Skip to content

Commit

Permalink
Setting min java version to 11 and updates dependencies (#699)
Browse files Browse the repository at this point in the history
  • Loading branch information
haroon-sheikh authored Jun 22, 2023
1 parent 2f185e9 commit ae02dd2
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .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: ['16', '17']
java_version: ['11', '17']
steps:
- uses: actions/checkout@v2

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This project adds java [language plugin](https://gauge.org/plugins/) for [gauge]
### Pre-requisite

- [Install Gauge](https://docs.gauge.org/getting_started/installing-gauge.html)
- [Java](https://www.java.com/en/download/)
- [Java](https://www.java.com/en/download/) (Minimum required version is 11)

### Installation

Expand All @@ -36,13 +36,13 @@ gauge run specs
#### Install specific version
* Installing specific version
```
gauge install java --version 0.9.2
gauge install java --version 0.10.0
```

#### Offline installation
* Download the plugin from [Releases](https://github.com/getgauge/gauge-java/releases)
```
gauge install java --file gauge-java-0.9.2-windows.x86_64.zip
gauge install java --file gauge-java-0.10.0-windows.x86_64.zip
```

#### Build from source
Expand Down
6 changes: 3 additions & 3 deletions gauge-java.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func getGaugeJavaDepFromMavenPom() (string, string, error) {
return matches[1], mavenPomFile, nil
}

func getGradleCommnad() string {
func getGradleCommand() string {
windowsGradleW := filepath.Join(projectRoot, gradleCommadWindows)
unixGradleW := filepath.Join(projectRoot, gradleCommadUnix)
if runtime.GOOS == "windows" && fileExists(windowsGradleW) {
Expand All @@ -157,14 +157,14 @@ func getGradleCommnad() string {

func getGaugeJavaDepFromGradleBuild() (string, string, error) {
args := []string{"-q", "dependencyInsight", "--dependency", "com.thoughtworks.gauge", "--configuration", "testCompileClasspath"}
cmd := exec.Command(getGradleCommnad(), args...)
cmd := exec.Command(getGradleCommand(), args...)
cmd.Stderr = os.Stderr
cmd.Dir = projectRoot
out, err := cmd.Output()
if err != nil {
return "", gradleBuildFile, err
}
re, err := regexp.Compile(`.*com\.thoughtworks\.gauge:gauge-java:(.*)`)
re, err := regexp.Compile(`.*com\.thoughtworks\.gauge:gauge-java:([^\s]+)`)
if err != nil {
return "", gradleBuildFile, fmt.Errorf("failed to compile regex. %w", err)
}
Expand Down
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.9.2",
"version": "0.10.0",
"description": "Java support for gauge",
"install": {
"windows": [],
Expand Down
116 changes: 59 additions & 57 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@
<version>${projectVersion}</version>
<description>Java plugin for Gauge</description>
<url>http://github.com/getgauge/gauge-java</url>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-bom</artifactId>
<version>1.56.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.22.0</version>
<version>3.24.2</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
Expand All @@ -28,36 +32,12 @@
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.16.3</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>4.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<version>1.19.0</version>
<scope>test</scope>
<version>3.25.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
Expand All @@ -67,42 +47,67 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220320</version>
<version>20230618</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.19.4</version>
<version>3.23.3</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
<version>32.0.1-jre</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.41.2</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.41.2</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.41.2</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.org.webcompere</groupId>
<artifactId>system-stubs-jupiter</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -142,7 +147,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -155,7 +160,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.2</version>
<version>3.5.0</version>
<configuration>
<excludePackageNames>com.google.protobuf</excludePackageNames>
</configuration>
Expand All @@ -166,7 +171,6 @@
<goal>jar</goal>
</goals>
<configuration>
<source>8</source>
<doclint>none</doclint>
</configuration>
</execution>
Expand All @@ -175,7 +179,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand All @@ -195,7 +199,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
Expand All @@ -206,22 +210,17 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
<version>3.11.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<version>3.3.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.1</version>
<version>10.12.0</version>
</dependency>
</dependencies>
<executions>
Expand All @@ -243,7 +242,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.2.0</version>
<version>3.6.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
Expand All @@ -261,7 +260,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<version>3.3.1</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
Expand Down Expand Up @@ -303,9 +302,12 @@

<properties>
<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
<projectVersion>0.9.2</projectVersion>
<projectVersion>0.10.0</projectVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
import gauge.messages.Messages;
import junit.framework.TestCase;
import org.assertj.core.util.Lists;
import org.hamcrest.Matchers;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -320,16 +322,19 @@ public void testResultForRefactoringWhenFileDoesNotExist() {

public void testJavaElementForRefactoringWithMethodWithComments() throws Exception {
StepRegistry registry = mock(StepRegistry.class);
StepValue oldStepValue = new StepValue("A step with comments", "A step with comments", new ArrayList<>());
StepValue newStepValue = new StepValue("with comments", "with comments", new ArrayList<>());
String oldStepText = "A step with comments";
String newStepText = "with comments";
StepValue oldStepValue = new StepValue(oldStepText, oldStepText, new ArrayList<>());
StepValue newStepValue = new StepValue(newStepText, newStepText, new ArrayList<>());
String implFile = String.format("test%sfiles%sformatted%sStepImpl.java", File.separator, File.separator, File.separator);
String parameterizedStepValue = "with comments";
JavaRefactoring refactoring = new JavaRefactoring(oldStepValue, newStepValue, new ArrayList<>(), registry, parameterizedStepValue, saveChanges);
JavaRefactoringElement element = refactoring.createJavaRefactoringElement(implFile);

assertEquals(getImplFile(implFile).getName(), element.getFile().getName());
String newLineChar = System.getProperty("line.separator");
assertTrue(element.getText().contains(" @Step(\"with comments\")" + newLineChar +
String actual = element.getText();
assertThat(actual, Matchers.containsString(" @Step(\"" + newStepText + "\")" + newLineChar +
" public void someStepWithComments() {" + newLineChar +
" // comment1" + newLineChar +
" // comment2" + newLineChar +
Expand All @@ -344,7 +349,7 @@ public void testJavaElementForRefactoringWithMethodWithComments() throws Excepti
" */" + newLineChar +
" System.out.println(\"\");" + newLineChar +
" }"));
assertFalse(element.getText().contains("A step with comments"));
assertFalse(actual.contains(oldStepText));
}

public void testRefactoringWithOrphanComments() throws RefactoringException {
Expand Down Expand Up @@ -372,13 +377,13 @@ public void testRefactoringWithOrphanComments() throws RefactoringException {
" comment8" + newLineChar +
" */" + newLineChar +
" System.out.println(\"\");" + newLineChar +
" // comment9" + newLineChar +
" // comment10" + newLineChar +
" /*" + newLineChar +
" // comment9" + newLineChar +
" // comment10" + newLineChar +
" /*" + newLineChar +
" comment11" + newLineChar +
" comment12" + newLineChar +
" */" + newLineChar +
" /*" + newLineChar +
" /*" + newLineChar +
" comment13" + newLineChar +
" comment14" + newLineChar +
" comment15" + newLineChar +
Expand All @@ -387,7 +392,7 @@ public void testRefactoringWithOrphanComments() throws RefactoringException {
String actualValue = element.getText();

assertEquals(getImplFile(implFile).getName(), element.getFile().getName());
assertTrue(actualValue.contains(expectedValue));
assertThat(actualValue, Matchers.containsString(expectedValue));
assertFalse(actualValue.contains("A step with comments"));
}

Expand Down
Loading

0 comments on commit ae02dd2

Please sign in to comment.