Skip to content

Commit

Permalink
Merge pull request #177 from hazendaz/main
Browse files Browse the repository at this point in the history
Minor code cleanup / allow GHA to work across branches + built in maven cache + maven wrapper on the fly
  • Loading branch information
hazendaz authored Apr 5, 2024
2 parents 74d63cf + 06ae1dc commit 6f024a6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 44 deletions.
23 changes: 8 additions & 15 deletions .github/workflows/maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,28 @@

name: mvn verify

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
on: [push, pull_request, workflow_dispatch]

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
java: [17]
java: [17, 21]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: zulu
- name: Cache local maven repository
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ matrix.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ matrix.os }}-m2
distribution: temurin
cache: 'maven'
- name: Download Maven Wrapper
run: mvn wrapper:wrapper "-Dmaven=3.9.6"
- name: Build with Maven
run: mvn -B -V -e "-Dstyle.color=always" verify -DskipFormat -DverifyFormat
run: ./mvnw -B -V -e "-Dstyle.color=always" verify -DskipFormat -DverifyFormat
env:
MAVEN_OPTS: -Djansi.force=true

Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class XmlDocumentFormatter {
* {@link XmlDocumentFormatter} object can be reused.
*/
private static class FormatState {
private int depth = 0;
private boolean lastNodeWasText = false;
private int depth;
private boolean lastNodeWasText;
private StringBuilder out = new StringBuilder(200);
}

Expand Down Expand Up @@ -187,7 +187,7 @@ public boolean requiresInitialIndent() {

private static class DoctypeDeclarationReader extends TagReader {

private boolean complete = false;
private boolean complete;

@Override
protected void clear() {
Expand Down Expand Up @@ -221,7 +221,7 @@ protected String readTag() throws IOException {

private static class ProcessingInstructionReader extends TagReader {

private boolean complete = false;
private boolean complete;

@Override
protected void clear() {
Expand Down Expand Up @@ -341,21 +341,11 @@ protected void clear() {
this.complete = false;
}

/*
* (non-Javadoc)
*
* @see org.eclipse.ant.internal.ui.editor.formatter.XmlDocumentFormatter.TagReader# getStartOfTag()
*/
@Override
public String getStartOfTag() {
return "";
}

/*
* (non-Javadoc)
*
* @see org.eclipse.ant.internal.ui.editor.formatter.XmlDocumentFormatter.TagReader# isTextNode()
*/
@Override
public boolean isTextNode() {
return this.isTextNode;
Expand Down Expand Up @@ -405,21 +395,11 @@ protected String readTag() throws IOException {
return node.toString();
}

/*
* (non-Javadoc)
*
* @see org.eclipse.ant.internal.ui.editor.formatter.XmlDocumentFormatter.TagReader# requiresInitialIndent()
*/
@Override
public boolean requiresInitialIndent() {
return false;
}

/*
* (non-Javadoc)
*
* @see org.eclipse.ant.internal.ui.editor.formatter.XmlDocumentFormatter.TagReader# startsOnNewline()
*/
@Override
public boolean startsOnNewline() {
return false;
Expand All @@ -428,7 +408,7 @@ public boolean startsOnNewline() {

private static class XmlElementReader extends TagReader {

private boolean complete = false;
private boolean complete;

@Override
protected void clear() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void testDeleteBlankLines() throws IOException {
Files.createDirectories(path.getParent());
Files.writeString(path, outXml, StandardOpenOption.CREATE);

assertEquals(outXml, Files.readString(Paths.get("src/test/resources/test-space-expected.xml")));
assertEquals(Files.readString(Paths.get("src/test/resources/test-space-expected.xml")), outXml);
}

@Test
Expand All @@ -47,7 +47,7 @@ void testDefaultPreferences() throws Exception {
Files.createDirectories(path.getParent());
Files.writeString(path, outXml, StandardOpenOption.CREATE);

assertEquals(outXml, Files.readString(Paths.get("src/test/resources/default-output.xml")));
assertEquals(Files.readString(Paths.get("src/test/resources/default-output.xml")), outXml);
}

@Test
Expand All @@ -63,7 +63,7 @@ void testMultiLinedAttrs() throws Exception {
Files.createDirectories(path.getParent());
Files.writeString(path, outXml, StandardOpenOption.CREATE);

assertEquals(outXml, Files.readString(Paths.get("src/test/resources/multi-lined-attrs-output.xml")));
assertEquals(Files.readString(Paths.get("src/test/resources/multi-lined-attrs-output.xml")), outXml);
}

@Test
Expand All @@ -79,7 +79,7 @@ void testNoWrapTags() throws Exception {
Files.createDirectories(path.getParent());
Files.writeString(path, outXml, StandardOpenOption.CREATE);

assertEquals(outXml, Files.readString(Paths.get("src/test/resources/no-wrap-tags-output.xml")));
assertEquals(Files.readString(Paths.get("src/test/resources/no-wrap-tags-output.xml")), outXml);
}

@Test
Expand Down

0 comments on commit 6f024a6

Please sign in to comment.