Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AOT Optimizations #868

Merged
merged 58 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
bf90177
refactor: extract OpenIdProviderMetadataFetcher
sdelamo Dec 16, 2021
71b10c7
aot wip
sdelamo Dec 21, 2021
c243d57
Use `StaticOptimizations` instead of `@Replaces`
melix Dec 21, 2021
21e3d52
Upgrade to AOT 1.0.0-M5
melix Dec 21, 2021
b912d84
setters WIP
sdelamo Dec 21, 2021
f1380eb
fix test
sdelamo Dec 22, 2021
8b8888c
move nullability check to method
sdelamo Dec 22, 2021
1c82448
simplify aot build
sdelamo Dec 22, 2021
3890f6b
define AOT version in gradle.properties
sdelamo Dec 22, 2021
2eb4dde
build: bump up micronaut to 3.2.3
sdelamo Dec 22, 2021
2dfae4e
build: runtime selenium chrome driver for tests
sdelamo Dec 22, 2021
3eb9b32
wip JwkSetFetcher
sdelamo Dec 22, 2021
b732e1c
Fix incorrect service declaration
melix Dec 22, 2021
92f7c2c
Fix typo in static initializer
melix Dec 22, 2021
cb50471
draft JwksFetcherCodeGenerator
sdelamo Dec 22, 2021
e8e0dd7
fix test
sdelamo Dec 22, 2021
b2eb5bc
Fix how static optimizations are injected
melix Dec 22, 2021
4a7ea92
Introduce AOT test suite
melix Dec 22, 2021
8f8fca0
use JsonMapper instead ObjectMapper
sdelamo Jan 3, 2022
b939f7d
Merge branch 'master' into extract-fetcher
sdelamo Jan 3, 2022
2ba8259
Upgrade to Micronaut AOT 1.0.0-M6
melix Jan 21, 2022
49ffe06
bump up to 1.0.0-M7
sdelamo Jan 31, 2022
eac2dd6
Merge branch 'master' into extract-fetcher
melix Mar 29, 2022
3c1f1b1
Merge branch 'master' into extract-fetcher
melix Mar 29, 2022
ba0798b
Merge branch 'main' into extract-fetcher
sdelamo Jul 22, 2022
dda72da
extract utils
sdelamo Jul 22, 2022
e0cd245
add JwksFetcherCodeGenerator
sdelamo Jul 22, 2022
d359adc
set version to 3.7.0
sdelamo Jul 22, 2022
273a344
Use it as a parameter of the factory method
sdelamo Jul 22, 2022
475ff5f
fix generated code
sdelamo Jul 22, 2022
5b9dc97
Merge branch '3.9.x' into extract-fetcher
sdelamo Nov 14, 2022
fbbe1c0
change since
sdelamo Nov 14, 2022
c099dc2
add author
sdelamo Nov 14, 2022
c37307c
annotate wtih @Internal
sdelamo Nov 14, 2022
8203256
build: enable TYPESAFE_PROJECT_ACCSSORS
sdelamo Nov 14, 2022
9cfe1c7
remove settings for test project
sdelamo Nov 14, 2022
e385626
build: use kotlin DSL
sdelamo Nov 14, 2022
2c89906
wip
sdelamo Nov 14, 2022
ab6fd76
add test scritp [skip ci]
sdelamo Nov 14, 2022
3e852a0
Add AOT test
sdelamo Nov 15, 2022
897240e
checkstyle: fix checkstyle issues
sdelamo Nov 15, 2022
b8e391f
add test for jwksfetcher
sdelamo Nov 15, 2022
0c55252
add docs
sdelamo Nov 15, 2022
e488d5e
fix since
sdelamo Nov 15, 2022
fd9de39
extract method
sdelamo Nov 15, 2022
0732006
remove -a
sdelamo Nov 15, 2022
c22834c
more verbose test
sdelamo Nov 15, 2022
eec7c43
added as implementation
sdelamo Nov 15, 2022
fbbbbd4
sonar: Format specifiers should be used instead of string concatenation
sdelamo Nov 15, 2022
a9746a2
sonar extract constant
sdelamo Nov 15, 2022
b71d6bc
sonar: remove extra line
sdelamo Nov 15, 2022
96de149
sonar: remove unused logger
sdelamo Nov 15, 2022
be50d93
checkstyle: remove unused import
sdelamo Nov 15, 2022
cfc2048
sonar: remove of generic wildcard type
sdelamo Nov 15, 2022
8a0ba17
Update test-suite-aot.sh
sdelamo Nov 15, 2022
e420598
add warnings
sdelamo Nov 16, 2022
7bcfa42
add version
sdelamo Nov 16, 2022
7e25b80
checkstyle: remove unused imports
sdelamo Nov 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/aot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Run AOT Tests
on:
push:
branches:
- master
- '[1-9]+.[0-9]+.x'
pull_request:
branches:
- master
- '[1-9]+.[0-9]+.x'
jobs:
build:
if: github.repository != 'micronaut-projects/micronaut-project-template'
runs-on: ubuntu-latest
strategy:
matrix:
java: ['17']
steps:
# https://github.com/actions/virtual-environments/issues/709
- name: Free disk space
run: |
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo apt-get clean
df -h
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run AOT Tests
run: ./test-suite-aot.sh
env:
TESTCONTAINERS_RYUK_DISABLED: true
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
PREDICTIVE_TEST_SELECTION: "${{'false'}}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugins {
id "io.micronaut.build.internal.security-base"
id "io.micronaut.build.internal.module"
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ projectUrl=https://micronaut.io
githubSlug=micronaut-projects/micronaut-security
developers=James Kleeh,Sergio del Amo

micronautAotVersion=1.1.1
micronautGradlePluginVersion=3.6.3
githubCoreBranch=3.8.x

bomProperty=micronautSecurityVersion
Expand Down
25 changes: 25 additions & 0 deletions security-aot/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
plugins {
id("io.micronaut.build.internal.aot-module")
}
micronautBuild {
aot {
version.set("1.1.1")
}
}
micronautBuild {
binaryCompatibility {
enabled.set(false)
}
}
dependencies {
compileOnly(platform(mn.micronaut.bom))
implementation(projects.securityOauth2)
implementation(projects.securityJwt)

testImplementation(mn.spock) {
exclude("org.codehaus.groovy", "groovy-all")
}
testImplementation(platform(mn.micronaut.bom))
testImplementation(mn.micronaut.http.server.netty)
testImplementation(projects.securityOauth2)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright 2017-2022 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.security.aot;

import io.micronaut.aot.core.AOTContext;
import io.micronaut.context.Qualifier;
import io.micronaut.core.annotation.Internal;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.annotation.Nullable;

import java.util.Collection;

/**
* Utility to retrieve beans from the Application Context associated to the AOT Context.
* @author Sergio del Amo
* @since 3.9.0
*/
@Internal
public final class AOTContextUtils {
private AOTContextUtils() {

}

/**
* Get all beans of the given type.
*
* @param beanType The bean type
* @param <T> The bean type parameter
* @param aotContext The AOT Context
* @return The found beans
*/
@NonNull
public static <T> Collection<T> getBeansOfType(@NonNull Class<T> beanType, @NonNull AOTContext aotContext) {
return aotContext.getAnalyzer()
.getApplicationContext()
.getBeansOfType(beanType);
}

/**
* Obtains a Bean for the given type.
*
* @param beanType The bean type
* @param <T> The bean type parameter
* @param aotContext The AOT Context
* @return An instanceof said bean
* @throws io.micronaut.context.exceptions.NonUniqueBeanException When multiple possible bean definitions exist
* for the given type
* @throws io.micronaut.context.exceptions.NoSuchBeanException If the bean doesn't exist
*/
@NonNull
public static <T> T getBean(@NonNull Class<T> beanType, @NonNull AOTContext aotContext) {
return aotContext.getAnalyzer()
.getApplicationContext()
.getBean(beanType);
}

/**
* Return whether the bean of the given type is contained within this context.
*
* @param beanType The bean type
* @param qualifier The qualifier for the bean
* @param <T> The concrete type
* @param aotContext The AOT Context
* @return True if it is
*/
@NonNull
public static <T> boolean containsBean(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier, @NonNull AOTContext aotContext) {
return aotContext.getAnalyzer()
.getApplicationContext()
.containsBean(beanType, qualifier);
}

/**
* Obtains a Bean for the given type and qualifier.
*
* @param beanType The bean type
* @param qualifier The qualifier
* @param <T> The bean type parameter
* @param aotContext The AOT Context
* @return An instanceof said bean
* @throws io.micronaut.context.exceptions.NonUniqueBeanException When multiple possible bean definitions exist
* for the given type
* @see io.micronaut.inject.qualifiers.Qualifiers
*/
@NonNull
public static <T> T getBean(@NonNull Class<T> beanType, @Nullable Qualifier<T> qualifier, @NonNull AOTContext aotContext) {
return aotContext.getAnalyzer()
.getApplicationContext()
.getBean(beanType, qualifier);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright 2017-2021 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.security.aot;

import com.squareup.javapoet.JavaFile;
import io.micronaut.core.annotation.Internal;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.naming.Named;

/**
* A generated file.
* @author Sergio del Amo
* @since 3.9.0
*/
@Internal
public class GeneratedFile implements Named {

@NonNull
private final String name;

@NonNull
private final String simpleName;

@NonNull
private final JavaFile javaFile;

/**
*
* @param name The name qualifier
* @param simpleName The simple filename
* @param javaFile The java file
*/
public GeneratedFile(@NonNull String name,
@NonNull String simpleName,
@NonNull JavaFile javaFile) {
this.name = name;
this.simpleName = simpleName;
this.javaFile = javaFile;
}

/**
*
* @return The name qualifier
*/
@Override
@NonNull
public String getName() {
return name;
}

/**
*
* @return The simple filename
*/
@NonNull
public String getSimpleName() {
return simpleName;
}

/**
*
* @return The java file
*/
@NonNull
public JavaFile getJavaFile() {
return javaFile;
}
}
Loading