Skip to content

Commit

Permalink
Merge pull request #85 from OP-TED/release/1.3.0
Browse files Browse the repository at this point in the history
Release/1.3.0
  • Loading branch information
bertrand-lorentz authored Jul 25, 2023
2 parents 361c402 + 19c4166 commit eafaa82
Show file tree
Hide file tree
Showing 38 changed files with 1,417 additions and 341 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build the project
on:
push:

# Allows to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Build package
run: mvn --batch-mode clean install -s .github/workflows/settings.xml
18 changes: 10 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Publish package to the Maven Central Repository

on:
push:
branches:
- 'develop'
- 'main'

release:
types: [created]

Expand All @@ -16,20 +21,17 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v1
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Publish to the Maven Central Repository
run: mvn --batch-mode deploy -Dgpg.passphrase='${{ secrets.GPG_PASSPHRASE }}' -Prelease
run: mvn --batch-mode deploy -Dgpg.passphrase='${{ secrets.GPG_PASSPHRASE }}' -Prelease -s .github/workflows/settings.xml
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>ossrh</id>
<username>${env.MAVEN_USERNAME}</username>
<password>${env.MAVEN_PASSWORD}</password>
</server>
</servers>

<profiles>
<profile>
<id>repositories</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>ossrh</id>
<name>OSSRH Snapshots</name>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
14 changes: 7 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# EFX Toolkit 1.2.0 Release Notes
# EFX Toolkit 1.3.0 Release Notes

_The EFX Toolkit for Java developers is a library that enables the transpilation of [EFX](https://docs.ted.europa.eu/eforms/latest/efx) expressions and templates to different target languages. It also includes an implementation of an EFX-to-XPath transpiler._

---
## In this release:

- We fixed a bug in the `XPathScriptGenerator` that was causing references to fields of type `measure` (duration) to throw an exception when multiple values where matched by the reference.
- We fixed an issue in the `SdkSymbolResolver` that was causing some code labels to be resolved incorrectly. The `SdkSymbolResolver` now correctly looks for the root codelist associated with a field in the codelist metadata provided in the `codelists` folder, instead of relying on the codelist constraint metadata provided in `fields.json`.
:warning: _**CAUTION:** If you have implemented your own `SymbolResolver` make sure that your implementation of `getRootCodelistOfField` retrieves the parent codelist information from `codelists/codelists.json` or directly from the `.gc` files in the `codelists` folder of the eForms SDK._
- We refactored the code to move to the [eForms Core Java](https://github.com/OP-TED/eforms-core-java) library some common entity classes that were not specific to EFX (`SdkEntityFactory`, `SdkField`, `SdkNode`, `SdkCodelist`). We also moved into the EFX Toolkit some reusable classes (`SdkSymbolResolver`, `ComponentFactory`) from the [eForms Notice Viewer](https://github.com/OP-TED/eforms-notice-viewer) sample application. The result of this refactoring is `efx-toolkit-java`-`1.2.0`, `eforms-core-java`-`1.0.0` and `eforms-notice-viewer`-`0.6.0`.
- Updated the XPath 2.0 parser, XPathContextualizer and XPathScriptGenerator to correctly translate sequences.
- Improved numeric formatting. The EfxTranslator API now includes overloaded methods that permit control of numeric formatting. The existing API has been preserved.
- Improved handling of multilingual text fields by adding automatic selection of the visualisation language.

---

You can download the latest EFX Toolkit from Maven Central.
[![Maven Central](https://img.shields.io/maven-central/v/eu.europa.ted.eforms/efx-toolkit-java?label=Download%20&style=flat-square)](https://search.maven.org/search?q=g:%22eu.europa.ted.eforms%22%20AND%20a:%22efx-toolkit-java%22)
[![Maven Central](https://img.shields.io/maven-central/v/eu.europa.ted.eforms/efx-toolkit-java?label=Download%20&style=flat-square)](https://central.sonatype.com/artifact/eu.europa.ted.eforms/efx-toolkit-java)

Documentation for the EFX Toolkit is available at: https://docs.ted.europa.eu/eforms/latest/efx-toolkit

Expand All @@ -23,4 +23,4 @@ This version of the EFX Toolkit has a compile-time dependency on the following v
- eForms SDK 0.7.x
- eForms SDK 1.x.x

It also depends on the [eForms Core Java library](https://github.com/OP-TED/eforms-core-java) version 1.0.0.
It also depends on the [eForms Core Java library](https://github.com/OP-TED/eforms-core-java) version 1.0.5.
40 changes: 37 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**[:memo: Latest Release Notes](CHANGELOG.md)** | **[:package: Latest Release Artifacts](https://search.maven.org/search?q=g:%22eu.europa.ted.eforms%22%20AND%20a:%22efx-toolkit-java%22)**
**[:memo: Latest Release Notes](CHANGELOG.md)** | **[:package: Latest Release Artifacts](https://central.sonatype.com/artifact/eu.europa.ted.eforms/efx-toolkit-java)**

---
# Java toolkit for the eForms Expression Language (EFX)
Expand Down Expand Up @@ -36,6 +36,40 @@ You can build this project as usual using Maven.

The build process uses the grammar files provided in the [eForms SDK](https://github.com/OP-TED/eForms-SDK/tree/develop/efx-grammar) to generate a parser, using [ANTLR4](https://www.antlr.org).

In order to be able to use snapshot versions of dependencies, the following should be added to the "profiles" section of the Maven configuration file "settings.xml" (normally under ${HOME}/.m2):

```
<servers>
<server>
<id>ossrh</id>
<username>${env.MAVEN_USERNAME}</username>
<password>${env.MAVEN_PASSWORD}</password>
</server>
</servers>
<profile>
<id>repositories</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>ossrh</id>
<name>OSSRH Snapshots</name>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
```

See ".github/workflows/settings.xml".

## Testing

Unit tests are available under `src/test/java/`. They show in particular a variety of EFX expressions and the corresponding XPath expression.
Expand All @@ -47,10 +81,10 @@ The report is available under `target/site/jacoco/`, in HTML, CSV, and XML forma

You can download the latest EFX Toolkit from Maven Central.

[![Maven Central](https://img.shields.io/maven-central/v/eu.europa.ted.eforms/efx-toolkit-java?label=Download%20&style=flat-square)](https://search.maven.org/search?q=g:%22eu.europa.ted.eforms%22%20AND%20a:%22efx-toolkit-java%22)
[![Maven Central](https://img.shields.io/maven-central/v/eu.europa.ted.eforms/efx-toolkit-java?label=Download%20&style=flat-square)](https://central.sonatype.com/artifact/eu.europa.ted.eforms/efx-toolkit-java)

[^1]: _Copyright 2022 European Union_
_Licensed under the EUPL, Version 1.2 or – as soon they will be approved by the European Commission –
subsequent versions of the EUPL (the "Licence");_
_You may not use this work except in compliance with the Licence. You may obtain [a copy of the Licence here](LICENSE)._
_Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Licence for the specific language governing permissions and limitations under the Licence._
_Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Licence for the specific language governing permissions and limitations under the Licence._
38 changes: 33 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>eu.europa.ted.eforms</groupId>
<artifactId>efx-toolkit-java</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
<packaging>jar</packaging>

<name>EFX Toolkit for Java</name>
Expand Down Expand Up @@ -39,24 +39,27 @@
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
<url>https://${sonatype.server.url}/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<url>https://${sonatype.server.url}/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputTimestamp>2023-05-30T06:25:09Z</project.build.outputTimestamp>

<sonatype.server.url>s01.oss.sonatype.org</sonatype.server.url>

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

<sdk.antlr4.dir>${project.build.directory}/eforms-sdk/antlr4</sdk.antlr4.dir>

<!-- Versions - eForms -->
<version.eforms-core>1.0.0</version.eforms-core>
<version.eforms-core>1.0.5</version.eforms-core>

<!-- Versions - Third-party libraries -->
<version.antlr4>4.9.3</version.antlr4>
Expand All @@ -72,8 +75,10 @@
<version.dependency.plugin>3.3.0</version.dependency.plugin>
<version.install.plugin>2.5.2</version.install.plugin>
<version.jacoco.plugin>0.8.8</version.jacoco.plugin>
<version.jar.plugin>3.2.0</version.jar.plugin>
<version.javadoc.plugin>3.4.0</version.javadoc.plugin>
<version.pgp.plugin>1.5</version.pgp.plugin>
<version.nexus-staging.plugin>1.6.7</version.nexus-staging.plugin>
<version.source.plugin>3.2.1</version.source.plugin>
<version.surefire.plugin>3.0.0-M7</version.surefire.plugin> <!-- Versions prior to 3.0.x do not pick up Junit 5 tests correctly. -->
</properties>
Expand Down Expand Up @@ -194,6 +199,11 @@
<artifactId>jacoco-maven-plugin</artifactId>
<version>${version.jacoco.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${version.jar.plugin}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand All @@ -209,6 +219,11 @@
<artifactId>maven-source-plugin</artifactId>
<version>${version.source.plugin}</version>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${version.nexus-staging.plugin}</version>
</plugin>
</plugins>
</pluginManagement>

Expand All @@ -231,7 +246,7 @@
<artifactItem>
<groupId>eu.europa.ted.eforms</groupId>
<artifactId>eforms-sdk</artifactId>
<version>1.2.1</version>
<version>1.7.0</version>
<type>jar</type>
<includes>eforms-sdk/efx-grammar/**/*.g4</includes>
<outputDirectory>${sdk.antlr4.dir}/eu/europa/ted/efx/sdk1</outputDirectory>
Expand Down Expand Up @@ -342,6 +357,9 @@
<profile>
<!-- Profile "release" caters to the requirements for releasing to Maven Central -->
<id>release</id>
<properties>
<maven.compiler.debug>false</maven.compiler.debug>
</properties>
<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -388,6 +406,16 @@
</gpgArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://${sonatype.server.url}/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Expand Down
11 changes: 4 additions & 7 deletions src/main/antlr4/eu/europa/ted/efx/xpath/XPath20.g4
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
//
// This is a faithful implementation of the XPath version 2.0 grammar
// from the spec at https://www.w3.org/TR/xpath20/
//
// Note: Some minor adoptations were done
// to simplify the translator using this grammar.

grammar XPath20;


// [1]
xpath : expr EOF ;
expr : exprsingle ( COMMA exprsingle)* ;
Expand Down Expand Up @@ -43,8 +39,8 @@ nodecomp : KW_IS | LL | GG ;
// [25]
pathexpr : ( SLASH relativepathexpr?) | ( SS relativepathexpr) | relativepathexpr ;
relativepathexpr : stepexpr (( SLASH | SS) stepexpr)* ;
stepexpr : step predicatelist;
step: primaryexpr | reversestep | forwardstep;
stepexpr : filterexpr | axisstep ;
axisstep : (reversestep | forwardstep) predicatelist ;
forwardstep : (forwardaxis nodetest) | abbrevforwardstep ;
// [30]
forwardaxis : ( KW_CHILD COLONCOLON) | ( KW_DESCENDANT COLONCOLON) | ( KW_ATTRIBUTE COLONCOLON) | ( KW_SELF COLONCOLON) | ( KW_DESCENDANT_OR_SELF COLONCOLON) | ( KW_FOLLOWING_SIBLING COLONCOLON) | ( KW_FOLLOWING COLONCOLON) | ( KW_NAMESPACE COLONCOLON) ;
Expand All @@ -56,6 +52,7 @@ abbrevreversestep : DD ;
nodetest : kindtest | nametest ;
nametest : qname | wildcard ;
wildcard : STAR | (NCName CS) | ( SC NCName) ;
filterexpr : primaryexpr predicatelist ;
predicatelist : predicate* ;
// [40]
predicate : OB expr CB ;
Expand Down Expand Up @@ -343,4 +340,4 @@ fragment FragChar : '\u0009' | '\u000a' | '\u000d'
Whitespace : ('\u000d' | '\u000a' | '\u0020' | '\u0009')+ -> skip ;

// Not per spec. Specified for testing.
SEMI : ';' ;
SEMI : ';' ;
10 changes: 6 additions & 4 deletions src/main/java/eu/europa/ted/eforms/sdk/ComponentFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;

import eu.europa.ted.eforms.sdk.component.SdkComponentFactory;
import eu.europa.ted.eforms.sdk.component.SdkComponentType;
import eu.europa.ted.efx.interfaces.MarkupGenerator;
import eu.europa.ted.efx.interfaces.ScriptGenerator;
import eu.europa.ted.efx.interfaces.SymbolResolver;
import eu.europa.ted.efx.interfaces.TranslatorOptions;

public class ComponentFactory extends SdkComponentFactory {
public static final ComponentFactory INSTANCE = new ComponentFactory();
Expand Down Expand Up @@ -43,15 +45,15 @@ public static SymbolResolver getSymbolResolver(final String sdkVersion, final Pa
});
}

public static MarkupGenerator getMarkupGenerator(final String sdkVersion)
public static MarkupGenerator getMarkupGenerator(final String sdkVersion, TranslatorOptions options)
throws InstantiationException {
return ComponentFactory.INSTANCE.getComponentImpl(sdkVersion,
SdkComponentType.MARKUP_GENERATOR, MarkupGenerator.class);
SdkComponentType.MARKUP_GENERATOR, MarkupGenerator.class, options);
}

public static ScriptGenerator getScriptGenerator(final String sdkVersion)
public static ScriptGenerator getScriptGenerator(final String sdkVersion, TranslatorOptions options)
throws InstantiationException {
return ComponentFactory.INSTANCE.getComponentImpl(sdkVersion,
SdkComponentType.SCRIPT_GENERATOR, ScriptGenerator.class);
SdkComponentType.SCRIPT_GENERATOR, ScriptGenerator.class, options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import java.nio.file.Path;
import java.util.List;
import java.util.Map;

import org.antlr.v4.runtime.misc.ParseCancellationException;
import eu.europa.ted.eforms.sdk.SdkConstants;

import eu.europa.ted.eforms.sdk.component.SdkComponent;
import eu.europa.ted.eforms.sdk.component.SdkComponentType;
import eu.europa.ted.eforms.sdk.entity.SdkCodelist;
Expand Down
Loading

0 comments on commit eafaa82

Please sign in to comment.