Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-native-image
Browse files Browse the repository at this point in the history
  • Loading branch information
rbygrave authored Oct 24, 2023
2 parents 4431515 + f7c2f41 commit c39f223
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: maven
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
28 changes: 28 additions & 0 deletions .github/workflows/dependabot-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
# Enable for automerge
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
39 changes: 39 additions & 0 deletions .github/workflows/jdk-ea.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

name: JDK EA

on:
workflow_dispatch:
schedule:
- cron: '48 0 * * 6'

jobs:
build:

runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
java_version: [GA,EA]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
- name: Set up Java
uses: oracle-actions/setup-java@v1
with:
website: jdk.java.net
release: ${{ matrix.java_version }}
- name: Maven cache
uses: actions/cache@v3
env:
cache-name: maven-cache
with:
path:
~/.m2
key: build-${{ env.cache-name }}
- name: Build with Maven
run: mvn clean test

4 changes: 2 additions & 2 deletions blackbox-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>8.0.0.Final</version>
<version>8.0.1.Final</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -79,7 +79,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-api</artifactId>
<version>2.0-RC2</version>
<version>2.0-RC12</version>
</dependency>

<!-- test dependencies -->
Expand Down
1 change: 1 addition & 0 deletions blackbox-test/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
requires jakarta.validation;
requires jakarta.inject;
provides io.avaje.validation.Validator.GeneratedComponent with example.avaje.valid.GeneratedValidatorComponent;
provides io.avaje.inject.spi.Module with example.avaje.AvajeModule;
}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.avaje</groupId>
<artifactId>java11-oss</artifactId>
<version>3.10</version>
<version>3.12</version>
</parent>

<groupId>io.avaje</groupId>
Expand All @@ -27,7 +27,7 @@
<nexus.staging.autoReleaseAfterClose>true</nexus.staging.autoReleaseAfterClose>
<java.version>17</java.version>
<java.release>17</java.release>
<inject.version>9.4-RC3</inject.version>
<inject.version>9.8</inject.version>
<http.version>2.0-RC2</http.version>
</properties>

Expand Down
4 changes: 2 additions & 2 deletions validator-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-api</artifactId>
<version>2.0-RC5</version>
<version>2.0-RC12</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-inject</artifactId>
<version>9.5</version>
<version>9.8</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
getElements(round, ValidMethodPrism.PRISM_TYPE)
.map(ElementFilter::methodsIn)
.ifPresent(this::writeParamProviderForMethod);

writeAdaptersForImported(
round.getElementsAnnotatedWith(typeElement(ImportValidPojoPrism.PRISM_TYPE)));
getElements(round, ImportValidPojoPrism.PRISM_TYPE).ifPresent(this::writeAdaptersForImported);
initialiseComponent();
cascadeTypes();
writeComponent(round.processingOver());
Expand Down
2 changes: 1 addition & 1 deletion validator-http-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-api</artifactId>
<version>2.0-RC2</version>
<version>2.0-RC12</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void validate(Object bean, String acceptLanguage, Class<?>... groups) thr
}

@PostConstruct
void setValidator(BeanScope scope) {
public void setValidator(BeanScope scope) {
this.validator = scope.get(Validator.class);
}

Expand Down
8 changes: 7 additions & 1 deletion validator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-lang</artifactId>
<version>1.1</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-applog</artifactId>
<version>1.0</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-validator-http-plugin</artifactId>
Expand Down
5 changes: 4 additions & 1 deletion validator/src/main/java/io/avaje/validation/Validator.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ interface Builder {
/** Add a AnnotationValidationAdapter to use for the given type. */
<T> Builder add(Class<? extends Annotation> type, ValidationAdapter<T> adapter);

/** Lookup ResourceBundles with the given names for error message interpolation */
/**
* Lookup ResourceBundles with the given names for error message interpolation. This will
* attempt to load the bundles for every locale configured with this builder
*/
Builder addResourceBundles(String... bundleName);

/** Add ResourceBundles for error message interpolation */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package io.avaje.validation.core;

import static java.lang.System.Logger.Level.ERROR;
import static java.util.ResourceBundle.getBundle;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import io.avaje.applog.AppLog;
import io.avaje.lang.Nullable;

final class ResourceBundleManager {

private static final System.Logger logger = AppLog.getLogger(ResourceBundleManager.class);
private final Map<Locale, List<ResourceBundle>> map = new HashMap<>();
private static final List<ResourceBundle> EMPTY = List.of();
private static final String DEFAULT_BUNDLE = "io.avaje.validation.Messages";
Expand All @@ -30,14 +33,17 @@ final class ResourceBundleManager {
}
// since default is added last, it will be the last place messages will be resolved
addBundle(DEFAULT_BUNDLE, localeResolver.defaultLocale());

for (final Locale locale : localeResolver.otherLocales()) {
addBundle(DEFAULT_BUNDLE, locale);
}
}

private void addBundle(final String name, final Locale locale) {
map.computeIfAbsent(locale, key -> new ArrayList<>()).add(getBundle(name, locale));
try {
map.computeIfAbsent(locale, key -> new ArrayList<>()).add(getBundle(name, locale));
} catch (MissingResourceException e) {
logger.log(ERROR, "failed to load " + name + " with locale " + locale);
}
}

@Nullable
Expand Down
1 change: 1 addition & 0 deletions validator/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
exports io.avaje.validation.spi;

requires io.avaje.lang;
requires io.avaje.applog;
requires static io.avaje.inject;

uses io.avaje.validation.Validator.GeneratedComponent;
Expand Down

0 comments on commit c39f223

Please sign in to comment.