Skip to content

Commit 5d794a7

Browse files
authored
ensure -parameters is set for javac (#1877)
* ensure -parameters is set for javac * fix tests + more test annotation
1 parent 55c6cf0 commit 5d794a7

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

.github/workflows/ci-build.yml

+5
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,8 @@ jobs:
173173
echo "::add-matcher::.github/karatewindows-matcher.json"
174174
.\itests.cmd
175175
echo "::remove-matcher owner=karate-windows::"
176+
- name: Write out Unit Test report annotation for forked repo
177+
if: ${{ failure() && (github.event.pull_request.head.repo.full_name != github.repository) }}
178+
uses: mikepenz/action-junit-report@v5
179+
with:
180+
annotate_only: true # forked repo cannot write to checks so just do annotations

.github/workflows/report.yml

+21
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,27 @@ jobs:
1616
checks:
1717
runs-on: ubuntu-latest
1818
steps:
19+
- name: Set up GitHub CLI
20+
uses: actions/setup-gh@v2
21+
22+
- name: Get workflow run details
23+
id: workflow_details
24+
run: |
25+
gh api repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }} \
26+
--jq '.head_branch' > branch.txt
27+
BRANCH_NAME=$(cat branch.txt)
28+
echo "branch_name=${BRANCH_NAME}" >> $GITHUB_ENV
29+
30+
- name: Fetch PR number
31+
id: fetch_pr
32+
run: |
33+
PR=$(gh pr list --head "${{ env.branch_name }}" --json number --jq '.[0].number')
34+
echo "pr_number=${PR}" >> $GITHUB_ENV
35+
36+
- name: Output PR number
37+
run: |
38+
echo "The PR number is: ${{ env.pr_number }}"
39+
1940
- name: Download Test Report
2041
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2
2142
with:

src/main/java/dev/jbang/source/ProjectBuilder.java

+4
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,11 @@ private Project updateProjectMain(Source src, Project prj, ResourceResolver reso
471471
prj.setMainClass(src.tagReader.getMain().orElse(null));
472472
prj.setModuleName(src.tagReader.getModule().orElse(null));
473473
if (prj.getMainSource() instanceof JavaSource) {
474+
// todo: have way to turn these off? lets wait until someone asks and has a
475+
// usecase
476+
// where ability to debug and support named parameters is bad.
474477
prj.getMainSourceSet().addCompileOption("-g");
478+
prj.getMainSourceSet().addCompileOption("-parameters");
475479
}
476480
return updateProject(src, prj, resolver);
477481
}

src/test/java/dev/jbang/source/TestProjectBuilder.java

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
package dev.jbang.source;
22

33
import static org.hamcrest.MatcherAssert.assertThat;
4-
import static org.hamcrest.Matchers.*;
4+
import static org.hamcrest.Matchers.aMapWithSize;
5+
import static org.hamcrest.Matchers.anEmptyMap;
6+
import static org.hamcrest.Matchers.contains;
7+
import static org.hamcrest.Matchers.containsInAnyOrder;
8+
import static org.hamcrest.Matchers.equalTo;
9+
import static org.hamcrest.Matchers.hasEntry;
10+
import static org.hamcrest.Matchers.is;
11+
import static org.hamcrest.Matchers.iterableWithSize;
12+
import static org.hamcrest.Matchers.nullValue;
513
import static org.junit.jupiter.api.Assertions.assertThrows;
614

715
import java.io.IOException;
@@ -121,8 +129,9 @@ void testSourceTags() {
121129
assertThat(prj.getJavaVersion(), equalTo("11+"));
122130
assertThat(prj.getMainClass(), equalTo("mainclass"));
123131
assertThat(prj.getModuleName().get(), equalTo("mymodule"));
124-
assertThat(prj.getMainSourceSet().getCompileOptions(), iterableWithSize(3));
125-
assertThat(prj.getMainSourceSet().getCompileOptions(), contains("-g", "--enable-preview", "--verbose"));
132+
assertThat(prj.getMainSourceSet().getCompileOptions(), iterableWithSize(4));
133+
assertThat(prj.getMainSourceSet().getCompileOptions(),
134+
contains("-g", "-parameters", "--enable-preview", "--verbose"));
126135
assertThat(prj.isNativeImage(), is(Boolean.FALSE));
127136
assertThat(prj.getMainSourceSet().getNativeOptions(), iterableWithSize(2));
128137
assertThat(prj.getMainSourceSet().getNativeOptions(), contains("-O1", "-d"));
@@ -229,9 +238,9 @@ void testAliasSource() throws IOException {
229238
assertThat(prj.getJavaVersion(), equalTo("twojava"));
230239
assertThat(prj.getMainClass(), equalTo("mainclass")); // This is not updated from Alias here!
231240
assertThat(prj.getModuleName().get(), equalTo("mymodule")); // This is not updated from Alias here!
232-
assertThat(prj.getMainSourceSet().getCompileOptions(), iterableWithSize(4));
241+
assertThat(prj.getMainSourceSet().getCompileOptions(), iterableWithSize(5));
233242
assertThat(prj.getMainSourceSet().getCompileOptions(),
234-
contains("-g", "--enable-preview", "--verbose", "--ctwo"));
243+
contains("-g", "-parameters", "--enable-preview", "--verbose", "--ctwo"));
235244
assertThat(prj.isNativeImage(), is(Boolean.TRUE));
236245
assertThat(prj.getMainSourceSet().getNativeOptions(), iterableWithSize(4));
237246
assertThat(prj.getMainSourceSet().getNativeOptions(), contains("-O1", "-d", "-O1", "--ntwo"));

0 commit comments

Comments
 (0)