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

bump generator-jhipster to v8.5.0 #141

Merged
merged 10 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
13 changes: 12 additions & 1 deletion .blueprint/generate-sample/command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { readdir } from 'node:fs/promises';
import { GENERATOR_APP } from 'generator-jhipster/generators';

/**
* @type {import('generator-jhipster').JHipsterCommandDefinition}
*/
Expand All @@ -26,8 +28,16 @@ const command = {
type: String,
},
},
options: {},
configs: {
sampleName: {
prompt: gen => ({
when: !gen.all,
type: 'list',
message: 'which sample do you want to generate?',
choices: async () => readdir(gen.templatePath('samples')),
}),
scope: 'generator',
},
all: {
description: 'Generate every sample in a workspace',
cli: {
Expand All @@ -36,6 +46,7 @@ const command = {
scope: 'generator',
},
},
options: {},
import: [GENERATOR_APP],
};

Expand Down
10 changes: 1 addition & 9 deletions .blueprint/generate-sample/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,7 @@ export default class extends BaseGenerator {
get [BaseGenerator.PROMPTING]() {
return this.asPromptingTaskGroup({
async askForSample() {
if (!this.sampleName && !this.all) {
const answers = await this.prompt({
type: 'list',
name: 'sampleName',
message: 'which sample do you want to generate?',
choices: async () => readdir(this.templatePath('samples')),
});
this.sampleName = answers.sampleName;
}
await this.promptCurrentJHipsterCommand();
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"env": {
"node": true,
"es2020": true
"es2022": true
},
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"parserOptions": {
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,15 @@ jobs:
- run: ls ~/Library/Caches/Homebrew/
if: runner.os == 'macOS' && steps.compare.outputs.equals != 'true'

- name: 'TESTS: backend tests'
- run: npm run ci:backend:test
if: steps.compare.outputs.equals != 'true'
run: npm run ci:backend:test
# Native build is memory intensive, containers should not be started.
- name: 'TESTS: build application package'
- run: npm run native-package -- ${{ matrix.native-package-extra-args }}
if: steps.compare.outputs.equals != 'true'
timeout-minutes: 60
run: npm run native-package -- ${{ matrix.native-package-extra-args }}
- name: 'TESTS: run e2e'
run: npm run native-e2e --if-present
- run: npm run services:up
if: matrix.e2e != 'false' && steps.compare.outputs.equals != 'true'
- run: npm run native-e2e --if-present
if: matrix.e2e != 'false' && steps.compare.outputs.equals != 'true'
- name: Dump docker logs
if: always() && matrix.e2e != 'false' && steps.compare.outputs.equals != 'true'
Expand Down
1 change: 1 addition & 0 deletions .yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"written": true
}
},
"githubWorkflows": true,
"jhipsterVersion": "7.9.3",
"js": true,
"localBlueprint": false,
Expand Down
1 change: 1 addition & 0 deletions .yo-resolve
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
generators/** skip
README.md skip
cli/cli.cjs skip
.blueprint/github-build-matrix/build-matrix.mjs skip
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ If you've enabled e2e testing with Cypress, you can verify its operation using t
npm run native-e2e
```

## Build errors

GraalVM uses metadata to generate AOT compilation.
A metadata is designed to support an specific version. Missing library range will be added as best bet and will fall back to latest version.

Refer to [GraalVM Reachability Metadata Repository](https://github.com/oracle/graalvm-reachability-metadata/)

# Pre-release

To use an unreleased version, install it using npm + git repository.
Expand Down
78 changes: 63 additions & 15 deletions generators/server/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { extname } from 'node:path';
import { passthrough } from '@yeoman/transform';
import { isFileStateDeleted, isFileStateModified } from 'mem-fs-editor/state';
import ServerGenerator from 'generator-jhipster/generators/base-application';
import { javaMainPackageTemplatesBlock, addJavaAnnotation } from 'generator-jhipster/generators/java/support';
import { javaMainPackageTemplatesBlock, addJavaAnnotation, addJavaImport } from 'generator-jhipster/generators/java/support';
import { lt as semverLessThan } from 'semver';

import { NATIVE_BUILDTOOLS_VERSION } from '../../lib/constants.js';
import { mavenDefinition } from './support/index.js';
import { createNeedleCallback } from 'generator-jhipster/generators/base/support';

export default class extends ServerGenerator {
blueprintVersion;
Expand All @@ -31,6 +32,33 @@ export default class extends ServerGenerator {
});
}

get [ServerGenerator.PREPARING]() {
return this.asPreparingTaskGroup({
addNativeHint({ source, application }) {
source.addNativeHint = ({ publicConstructors = [], declaredConstructors = [] }) => {
this.editFile(
`${application.javaPackageSrcDir}config/NativeConfiguration.java`,
addJavaImport('org.springframework.aot.hint.MemberCategory'),
createNeedleCallback({
contentToAdd: [
...publicConstructors.map(
classPath =>
`hints.reflection().registerType(${classPath}, (hint) -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));`,
),
...declaredConstructors.map(
classPath =>
`hints.reflection().registerType(${classPath}, (hint) -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS));`,
),
],
needle: 'add-native-hints',
ignoreWhitespaces: true,
}),
);
};
},
});
}

get [ServerGenerator.DEFAULT]() {
return this.asDefaultTaskGroup({
// workaround for https://github.com/spring-projects/spring-boot/issues/32195
Expand Down Expand Up @@ -128,13 +156,37 @@ export default class extends ServerGenerator {

get [ServerGenerator.POST_WRITING]() {
return this.asPostWritingTaskGroup({
hints({ application: { mainClass, javaPackageSrcDir, packageName } }) {
hints({ application, source }) {
const { mainClass, javaPackageSrcDir, packageName } = application;

this.editFile(`${javaPackageSrcDir}${mainClass}.java`, { assertModified: true }, contents =>
addJavaAnnotation(contents, { package: 'org.springframework.context.annotation', annotation: 'ImportRuntimeHints' }).replaceAll(
'@ImportRuntimeHints\n',
`@ImportRuntimeHints({ ${packageName}.config.NativeConfiguration.JHipsterNativeRuntimeHints.class })\n`,
),
);

if (application.databaseMigrationLiquibase) {
// Latest liquibase version supported by Reachability Repository is 4.23.0
// Hints may be dropped if newer version is supported
// https://github.com/oracle/graalvm-reachability-metadata/blob/master/metadata/org.liquibase/liquibase-core/index.json
source.addNativeHint({
publicConstructors: ['liquibase.ui.LoggerUIService.class'],
declaredConstructors: [
'liquibase.database.LiquibaseTableNamesFactory.class',
'liquibase.report.ShowSummaryGeneratorFactory.class',
],
});
}

if (application.databaseTypeSql && !application.reactive) {
// Latest hibernate-core version supported by Reachability Repository is 6.5.0.Final
// Hints may be dropped if newer version is supported
// https://github.com/oracle/graalvm-reachability-metadata/blob/master/metadata/org.hibernate.orm/hibernate-core/index.json
source.addNativeHint({
publicConstructors: ['org.hibernate.binder.internal.BatchSizeBinder.class'],
});
}
},

async packageJson({ application: { buildToolMaven, buildToolGradle } }) {
Expand Down Expand Up @@ -243,16 +295,14 @@ import org.springframework.security.oauth2.core.oidc.user.OidcUser;`,
// workaround for arch error in backend:unit:test caused by gradle's org.graalvm.buildtools.native plugin
technicalStructureTest({ application: { buildToolGradle, javaPackageTestDir } }) {
if (!buildToolGradle) return;
this.editFile(`${javaPackageTestDir}/TechnicalStructureTest.java`, { assertModified: true }, contents =>
contents.includes('__BeanFactoryRegistrations')
? contents
: contents
.replace(
'import static com.tngtech.archunit.core.domain.JavaClass.Predicates.belongToAnyOf;',
`import static com.tngtech.archunit.core.domain.JavaClass.Predicates.belongToAnyOf;
import static com.tngtech.archunit.core.domain.JavaClass.Predicates.simpleNameEndingWith;`,
)
.replace(
this.editFile(
`${javaPackageTestDir}/TechnicalStructureTest.java`,
{ assertModified: true },
addJavaImport('com.tngtech.archunit.core.domain.JavaClass.Predicates.simpleNameEndingWith', { staticImport: true }),
contents =>
contents.includes('__BeanFactoryRegistrations')
? contents
: contents.replace(
'.ignoreDependency(belongToAnyOf',
`.ignoreDependency(simpleNameEndingWith("_BeanFactoryRegistrations"), alwaysTrue())
.ignoreDependency(belongToAnyOf`,
Expand All @@ -264,9 +314,7 @@ import org.springframework.security.oauth2.core.oidc.user.OidcUser;`,
if (!application.authenticationTypeOauth2) return;

// Increase wait for macos. Keyclock container start can take over 3 min. 4 min is not enough to download/start containers/start server.
this.editFile('src/main/docker/keycloak.yml', { assertModified: true }, content =>
content.replace('start_period: 10s', 'start_period: 30s').replace('retries: 20', 'retries: 60'),
);
this.editFile('src/main/docker/keycloak.yml', { assertModified: true }, content => content.replace('retries: 20', 'retries: 100'));

const awaitScript = this.packageJson.getPath('scripts.ci:server:await');
if (awaitScript) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class NativeConfiguration {
<%_ if (databaseMigrationLiquibase) { _%>
hints.resources().registerPattern("config/liquibase/*");
<%_ } _%>
// jhipster-needle-add-native-hints - JHipster will add native hints here
}
}
}
Loading
Loading