Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,30 @@ exports[`git-changes generators/spring-boot/generators/data-relational/index.ts
}
`;

exports[`git-changes generators/spring-boot/generators/graalvm/index.ts should match changes snapshot 1`] = `
{
"angular": false,
"angularWorkflow": false,
"base": false,
"ci": false,
"client": false,
"common": false,
"devBlueprint": false,
"devserverWorkflow": false,
"e2e": false,
"generateBlueprint": false,
"graalvm": false,
"java": true,
"react": false,
"reactWorkflow": false,
"sonarPr": false,
"springBootDefaults": false,
"vue": false,
"vueWorkflow": false,
"workspaces": false,
}
`;

exports[`git-changes generators/spring-boot/generators/jwt/index.ts should match changes snapshot 1`] = `
{
"angular": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
-%>
import { entityConfirmDeleteButtonSelector, entityCreateCancelButtonSelector, entityCreateSaveButtonSelector, entityDeleteButtonSelector, entityDetailsBackButtonSelector, entityDetailsButtonSelector, entityEditButtonSelector } from 'support/entity';
import {
<%_ if (generateUserManagement && !userManagement.generateEntityCypress) { _%>
userManagementPageHeadingSelector,
<%_ } _%>
<%_ if (withAdminUi) { _%>
metricsPageHeadingSelector,
healthPageHeadingSelector,
Expand All @@ -46,15 +43,6 @@ describe('/admin', () => {
cy.visit('');
});

<%_ if (generateUserManagement && !userManagement.generateEntityCypress) { _%>
describe('/user-management', () => {
it('should load the page', () => {
cy.clickOnAdminMenuItem('user-management');
cy.get(userManagementPageHeadingSelector).should('be.visible');
});
});
<%_ } _%>

<%_ if (withAdminUi) { _%>
describe('/metrics', () => {
it('should load the page', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ const otherEntities = this._.uniq(Object.values(differentRelationships).filter(r
// We cannot generate a required entity with relationship with required relationships.
const skipCreateTest =
(
graalvmSupport ||
!cypressBootstrapEntities ||
requiredRelationships.some(rel => rel.otherEntity.primaryKey && rel.otherEntity.primaryKey.derived) ||
requiredRelationships.some(rel => rel.otherEntity.builtInUser || rel.otherEntity === this.entity) ||
requiredRelationships.map(rel => rel.otherEntity.relationships).flat().some(rel => rel.relationshipRequired) ||
!entityFakeData
) ? '.skip' : '';

const reason = graalvmSupport ? 'graalvm is failing.' : 'cannot create a required entity with relationship with required relationships.';

const sampleFields = fields.filter(f => !f.autoGenerate && !f.nullable);

if (workaroundEntityCannotBeEmpty && sampleFields.length === 0) {
Expand Down Expand Up @@ -284,7 +287,7 @@ describe('<%- entityNameCapitalized %> e2e test', () => {

<%_ } _%>
<%_ if (!readOnly) { _%>
<% if (skipCreateTest) { %>// Reason: cannot create a required entity with relationship with required relationships.<% } %>
<% if (skipCreateTest) { %>// Reason: <%- reason %><% } %>
it<%= skipCreateTest %>('last delete button click should delete instance of <%- entityNameCapitalized %>', () => {
<%_ if (clientFrameworkReact) { _%>
cy.intercept('GET', '/<%= baseApi + entityApiUrl %>/*').as('dialogDeleteRequest');
Expand Down Expand Up @@ -318,7 +321,7 @@ describe('<%- entityNameCapitalized %> e2e test', () => {
cy.getEntityCreateUpdateHeading('<%- entityNameCapitalized %>');
});

<% if (skipCreateTest) { %>// Reason: cannot create a required entity with relationship with required relationships.<% } %>
<% if (skipCreateTest) { %>// Reason: <%- reason %><% } %>
it<%= skipCreateTest %>('should create an instance of <%- entityNameCapitalized %>', () => {
<%_ fields.filter(field => (!field.id || !field.autoGenerate) && !field.hidden && !field.readonly).forEach((field) => {
const fieldName = field.fieldName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ export const submitInitResetPasswordSelector = '[data-cy="submit"]';
<%_ } _%>

// Administration
<%_ if (generateUserManagement && !userManagement.generateEntityCypress) { _%>
export const userManagementPageHeadingSelector = '[data-cy="<%- userManagement.entityNameCapitalized %>Heading"]';
<%_ } _%>
export const swaggerFrameSelector = 'iframe[data-cy="swagger-frame"]';
export const swaggerPageSelector = '[id="swagger-ui"]';
<%_ if (withAdminUi) { _%>
Expand Down
15 changes: 15 additions & 0 deletions generators/generate-blueprint/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,21 @@ exports[`generator - generate-blueprint with all option should match snapshot 1`
"generators/spring-boot/generators/data-relational/templates/template-file-spring-boot:data-relational.ejs": {
"stateCleared": "modified",
},
"generators/spring-boot/generators/graalvm/command.js": {
"stateCleared": "modified",
},
"generators/spring-boot/generators/graalvm/generator.js": {
"stateCleared": "modified",
},
"generators/spring-boot/generators/graalvm/generator.spec.js": {
"stateCleared": "modified",
},
"generators/spring-boot/generators/graalvm/index.js": {
"stateCleared": "modified",
},
"generators/spring-boot/generators/graalvm/templates/template-file-spring-boot:graalvm.ejs": {
"stateCleared": "modified",
},
"generators/spring-boot/generators/jwt/command.js": {
"stateCleared": "modified",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ describe('lookupGeneratorsNamespaces', () => {
"spring-boot:data-mongodb",
"spring-boot:data-neo4j",
"spring-boot:data-relational",
"spring-boot:graalvm",
"spring-boot:jwt",
"spring-boot:liquibase",
"spring-boot:oauth2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,42 +137,6 @@ exports[`generator - java-simple-application:graalvm with default options should
],
},
],
"addNativeHint": [
{
"publicMethods": [
"java.util.Locale.class",
],
"resources": [
"i18n/**",
],
},
],
"editJavaFile": [
[
"src/main/java/com/mycompany/myapp/JhipsterApp.java",
{
"annotations": [
{
"annotation": "ImportRuntimeHints",
"package": "org.springframework.context.annotation",
"parameters": [Function],
},
],
},
],
[
"src/main/java/com/mycompany/myapp//web/rest/errors/FieldErrorVM.java",
{
"annotations": [
{
"annotation": "RegisterReflectionForBinding",
"package": "org.springframework.aot.hint.annotation",
"parameters": [Function],
},
],
},
],
],
}
`;

Expand All @@ -186,56 +150,11 @@ exports[`generator - java-simple-application:graalvm with default options should
"version": "'NATIVE-BUILD-TOOLS-VERSION'",
},
],
"addNativeHint": [
{
"publicMethods": [
"java.util.Locale.class",
],
"resources": [
"i18n/**",
],
},
],
"applyFromGradle": [
{
"script": "gradle/native.gradle",
},
],
"editJavaFile": [
[
"src/main/java/com/mycompany/myapp/JhipsterApp.java",
{
"annotations": [
{
"annotation": "ImportRuntimeHints",
"package": "org.springframework.context.annotation",
"parameters": [Function],
},
],
},
],
[
"src/main/java/com/mycompany/myapp//web/rest/errors/FieldErrorVM.java",
{
"annotations": [
{
"annotation": "RegisterReflectionForBinding",
"package": "org.springframework.aot.hint.annotation",
"parameters": [Function],
},
],
},
],
[
"src/test/java/com/mycompany/myapp//TechnicalStructureTest.java",
{
"staticImports": [
"com.tngtech.archunit.core.domain.JavaClass.Predicates.simpleNameEndingWith",
],
},
[Function],
],
],
}
`;

Expand All @@ -244,9 +163,6 @@ exports[`generator - java-simple-application:graalvm with default options should
".yo-rc.json": {
"stateCleared": "modified",
},
"src/main/java/com/mycompany/myapp/config/NativeConfiguration.java": {
"stateCleared": "modified",
},
}
`;

Expand All @@ -258,8 +174,5 @@ exports[`generator - java-simple-application:graalvm with default options should
"gradle/native.gradle": {
"stateCleared": "modified",
},
"src/main/java/com/mycompany/myapp/config/NativeConfiguration.java": {
"stateCleared": "modified",
},
}
`;
80 changes: 0 additions & 80 deletions generators/java-simple-application/generators/graalvm/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ import { isFileStateDeleted, isFileStateModified } from 'mem-fs-editor/state';

import { JavaApplicationGenerator } from '../../../java/generator.ts';
import { addJavaAnnotation } from '../../../java/support/add-java-annotation.ts';
import { javaMainPackageTemplatesBlock } from '../../../java/support/files.ts';
import type { Application as LanguagesApplication } from '../../../languages/index.ts';
import type { Config as SpringBootConfig, Source as SpringBootSource } from '../../../spring-boot/index.ts';

import { GRAALVM_REACHABILITY_METADATA } from './internal/constants.ts';
import { mavenDefinition } from './internal/maven-definition.ts';
Expand All @@ -41,19 +39,6 @@ export default class GraalvmGenerator extends JavaApplicationGenerator {
}
}

get initializing() {
return this.asInitializingTaskGroup({
forceConfig() {
// Cache is not supported for GraalVM native image
(this.jhipsterConfig as SpringBootConfig).cacheProvider ??= 'no';
},
});
}

get [JavaApplicationGenerator.INITIALIZING]() {
return this.delegateTasksToBlueprint(() => this.initializing);
}

get preparing() {
return this.asPreparingTaskGroup({
loading({ applicationDefaults }) {
Expand Down Expand Up @@ -136,11 +121,6 @@ export default class GraalvmGenerator extends JavaApplicationGenerator {
await this.writeFiles({
sections: {
common: [{ templates: ['README.md.jhi.native'] }],
config: [
javaMainPackageTemplatesBlock({
templates: ['config/NativeConfiguration.java'],
}),
],
gradle: [
{
condition: ctx => ctx.buildToolGradle,
Expand Down Expand Up @@ -191,66 +171,6 @@ export default class GraalvmGenerator extends JavaApplicationGenerator {
}),
);
},

springBootHintsConfiguration({ application, source }) {
const { mainClass, javaPackageSrcDir, packageName, backendTypeSpringBoot } = application;

if (backendTypeSpringBoot) {
source.editJavaFile!(`${javaPackageSrcDir}${mainClass}.java`, {
annotations: [
{
package: 'org.springframework.context.annotation',
annotation: 'ImportRuntimeHints',
parameters: () => `{ ${packageName}.config.NativeConfiguration.JHipsterNativeRuntimeHints.class }`,
},
],
});
}
},

springBootRestErrors({ application, source }) {
const { javaPackageSrcDir, backendTypeSpringBoot } = application;
if (backendTypeSpringBoot) {
source.editJavaFile!(`${javaPackageSrcDir}/web/rest/errors/FieldErrorVM.java`, {
annotations: [
{
package: 'org.springframework.aot.hint.annotation',
annotation: 'RegisterReflectionForBinding',
parameters: () => '{ FieldErrorVM.class }',
},
],
});
}
},

// workaround for arch error in backend:unit:test caused by gradle's org.graalvm.buildtools.native plugin
springBootTechnicalStructureTest({ application, source }) {
const { buildToolGradle, javaPackageTestDir, backendTypeSpringBoot } = application;
if (!buildToolGradle || !backendTypeSpringBoot) return;
source.editJavaFile!(
`${javaPackageTestDir}/TechnicalStructureTest.java`,
{
staticImports: ['com.tngtech.archunit.core.domain.JavaClass.Predicates.simpleNameEndingWith'],
},
contents =>
contents.includes('__BeanFactoryRegistrations')
? contents
: contents.replace(
'.ignoreDependency(belongToAnyOf',
`.ignoreDependency(simpleNameEndingWith("_BeanFactoryRegistrations"), alwaysTrue())
.ignoreDependency(belongToAnyOf`,
),
);
},
nativeHints({ source, application }) {
if (!application.backendTypeSpringBoot) return;

(source as SpringBootSource).addNativeHint?.({
// Thymeleaf template
publicMethods: ['java.util.Locale.class'],
resources: ['i18n/**'],
});
},
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
nativeBuildTools = '0.11.4'
nativeBuildTools = '0.11.5'

[libraries]
nativeGradlePlugin = { module = 'org.graalvm.buildtools:native-gradle-plugin', version.ref = 'nativeBuildTools' }
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ processTestAot {
jvmArgs += ["-XX:+AllowRedefinitionToAddDeleteMethods"]
}
<%_ if (!reactive && databaseTypeSql) { _%>
<%_ if (devDatabaseTypeH2Any) { _%>
<%_ if (backendTypeSpringBoot && devDatabaseTypeH2Any) { _%>

processResources {
filesMatching("**/application-dev.yml") {
Expand Down
2 changes: 1 addition & 1 deletion generators/spring-boot/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default class SpringBootGenerator extends SpringBootApplicationGenerator
}

if (graalvmSupport) {
await this.composeWithJHipster('jhipster:java-simple-application:graalvm');
await this.composeWithJHipster('jhipster:spring-boot:graalvm');
}

if (enableSwaggerCodegen) {
Expand Down
Loading
Loading