Skip to content

Commit

Permalink
Merge pull request #26903 from mshima/maven-sort
Browse files Browse the repository at this point in the history
Don't sort maven dependency imports
  • Loading branch information
DanielFran authored Aug 6, 2024
2 parents b595349 + dae92d6 commit 9b50af5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
34 changes: 30 additions & 4 deletions generators/base/support/jhipster7-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@ import { upperFirstCamelCase } from './string.js';
const { BYTES, BYTE_BUFFER } = fieldTypes.RelationalOnlyDBTypes;

export const jhipster7deprecatedProperties = {
devDatabaseType: {
behaviorOnlyReason: 'v8: devDatabaseType is only used in jhipster:spring-data-relational generator',
get: ({ data }) => {
if (data.devDatabaseType === undefined) return data.devDatabaseType;
const fallbackValue = data.prodDatabaseType ?? data.databaseType;
// eslint-disable-next-line no-console
console.log(
`JHipster v8 behavior change(devDatabaseType is only used in jhipster:spring-data-relational generator): devDatabaseType is not set, using fallback: ${fallbackValue}`,
);
return fallbackValue;
},
},
prodDatabaseType: {
behaviorOnlyReason: 'v8: prodDatabaseType is only used in jhipster:spring-data-relational generator',
get: ({ data }) => data.prodDatabaseType ?? data.databaseType,
get: ({ data }) => {
if (data.prodDatabaseType === undefined) return data.prodDatabaseType;
// eslint-disable-next-line no-console
console.log(
`JHipster v8 behavior change(prodDatabaseType is only used in jhipster:spring-data-relational generator): devDatabaseType is not set, using fallback: ${data.databaseType}`,
);
return data.databaseType;
},
},
GRADLE_VERSION: {
replacement: 'gradleVersion',
get: ({ data }) => data.gradleVersion,
Expand Down Expand Up @@ -300,12 +324,14 @@ const getPropertBuilder =
const { generator, data } = context;
const value = prop in data ? data[prop] : undefined;
if (prop in jhipster7deprecatedProperties) {
const { replacement, get } = jhipster7deprecatedProperties[prop];
const { replacement, get, behaviorOnlyReason } = jhipster7deprecatedProperties[prop];
const fallBackValue = get(context);
const valueDesc = prop in data ? `Value: ${value}, ` : '';
log(
`Template data ${chalk.yellow(String(prop))} was removed and should be replaced with ${chalk.yellow(replacement)}. ${valueDesc}FallbackValue: ${fallBackValue}`,
);
if (!behaviorOnlyReason) {
log(
`Template data ${chalk.yellow(String(prop))} was removed and should be replaced with ${chalk.yellow(replacement)}. ${valueDesc}FallbackValue: ${fallBackValue}`,
);
}
return value ?? fallBackValue;
}
if (prop?.startsWith?.('DOCKER_')) {
Expand Down
12 changes: 9 additions & 3 deletions generators/maven/internal/pom-sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import sortKeys from 'sort-keys';

import { MavenArtifact, MavenProfile } from '../types.js';
import { MavenDependency, MavenProfile } from '../types.js';

export const formatPomFirstLevel = content =>
content.replace(
Expand Down Expand Up @@ -97,8 +97,14 @@ const comparator = (order: string[]) => (a: string, b: string) => sortWithTempla

const sortProperties = properties => sortKeys(properties, { compare: comparator(propertiesOrder) });

const sortArtifacts = (artifacts: MavenArtifact[]) =>
artifacts.sort((a: MavenArtifact, b: MavenArtifact) => {
const sortArtifacts = (artifacts: MavenDependency[]) =>
artifacts.sort((a: MavenDependency, b: MavenDependency) => {
if (a.scope === 'import' || b.scope === 'import') {
if (a.scope === b.scope) {
return 1;
}
return a.scope === 'import' ? -1 : 1;
}
if (a.groupId !== b.groupId) {
if (a.groupId === undefined) {
return -1;
Expand Down

0 comments on commit 9b50af5

Please sign in to comment.