Skip to content

Commit

Permalink
build: work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
khalilou88 committed Nov 30, 2023
1 parent 268cc6d commit f108119
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[versions]

[libraries]

[plugins]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[versions]

[libraries]

[plugins]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[versions]

[libraries]

[plugins]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[versions]

[libraries]

[plugins]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[versions]

[libraries]

[plugins]
9 changes: 9 additions & 0 deletions packages/nx-gradle/src/generators/init/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ function addFiles(tree: Tree, options: NormalizedSchema) {
options.gradleRootDirectory,
templateOptions,
);

if (options.versionManagement === 'version-catalog') {
generateFiles(
tree,
path.join(__dirname, 'files', 'gradle', 'catalog', options.preset),
'gradle',
templateOptions
);
}
}

export default initGenerator;
Expand Down
17 changes: 17 additions & 0 deletions testing-projects/e2e/nx-gradle-catalog-e2e/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
displayName: 'nx-gradle-catalog-e2e',
preset: '../../../jest.preset.js',
globals: {},
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
},
],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory:
'../../../coverage/e2e/nx-gradle-catalog-e2e',
};
18 changes: 18 additions & 0 deletions testing-projects/e2e/nx-gradle-catalog-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "nx-gradle-catalog-e2e",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "testing-projects/e2e/nx-gradle-catalog-e2e/src",
"targets": {
"e2e": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "testing-projects/e2e/nx-gradle-catalog-e2e/jest.config.js",
"runInBand": true
},
"dependsOn": ["nx-gradle:build"]
}
},
"tags": [],
"implicitDependencies": ["nx-gradle"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import { names, workspaceRoot } from '@nx/devkit';
import {
checkFilesExist,
cleanup,
readFile,
readJson,
runNxCommandAsync,
tmpProjPath,
uniq,
updateFile,
} from '@nx/plugin/testing';
import * as fse from 'fs-extra';
import * as path from 'path';

import { checkstyleVersion } from '@jnxplus/common';
import {
addTmpToGitignore,
patchPackageJson,
patchRootPackageJson,
removeTmpFromGitignore,
runNxNewCommand,
runPackageManagerInstallLinks,
} from '@jnxplus/internal/testing';

describe('nx-gradle version-catalog e2e', () => {
const isCI =
process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true';
const isWin = process.platform === 'win32';
const isMacOs = process.platform === 'darwin';
const rootProjectName = uniq('boot-root-project-');

beforeAll(async () => {
fse.ensureDirSync(tmpProjPath());
cleanup();
runNxNewCommand('', true);

const pluginName = '@jnxplus/nx-gradle';
const nxGradleDistAbsolutePath = path.join(
workspaceRoot,
'dist',
'packages',
'nx-gradle'
);

const commonDistAbsolutePath = path.join(
workspaceRoot,
'dist',
'packages',
'common'
);

const gradleDistAbsolutePath = path.join(
workspaceRoot,
'dist',
'packages',
'gradle'
);

patchRootPackageJson(pluginName, nxGradleDistAbsolutePath);
patchRootPackageJson('@jnxplus/common', commonDistAbsolutePath);
patchRootPackageJson('@jnxplus/gradle', gradleDistAbsolutePath);

patchPackageJson(
gradleDistAbsolutePath,
'@jnxplus/common',
commonDistAbsolutePath
);

patchPackageJson(
nxGradleDistAbsolutePath,
'@jnxplus/common',
commonDistAbsolutePath
);
patchPackageJson(
nxGradleDistAbsolutePath,
'@jnxplus/gradle',
gradleDistAbsolutePath
);

runPackageManagerInstallLinks();

await runNxCommandAsync(
`generate @jnxplus/nx-gradle:init --dsl kotlin --rootProjectName ${rootProjectName} --preset spring-boot --versionManagement version-catalog`
);

if (isCI) {
removeTmpFromGitignore();
}
}, 120000);

afterAll(async () => {
if (isCI) {
addTmpToGitignore();
}

// `nx reset` kills the daemon, and performs
// some work which can help clean up e2e leftovers
await runNxCommandAsync('reset');
});

it('should set NX_VERBOSE_LOGGING to true', async () => {
expect(process.env['NX_VERBOSE_LOGGING']).toBe('true');
}, 120000);

it('should use dsl option when initiating the workspace', async () => {
// Making sure the package.json file contains the @jnxplus/nx-gradle dependency
const packageJson = readJson('package.json');
expect(packageJson.devDependencies['@jnxplus/nx-gradle']).toBeTruthy();

// Making sure the nx.json file contains the @jnxplus/nx-gradle inside the plugins section
const nxJson = readJson('nx.json');
expect(nxJson.plugins.includes('@jnxplus/nx-gradle')).toBeTruthy();

expect(() =>
checkFilesExist(
'gradle/wrapper/gradle-wrapper.jar',
'gradle/wrapper/gradle-wrapper.properties',
'gradlew',
'gradlew.bat',
'gradle.properties',
'settings.gradle.kts',
'tools/linters/checkstyle.xml'
)
).not.toThrow();

expect(() =>
checkFilesExist(
`node_modules/@jnxplus/tools/linters/checkstyle/checkstyle-${checkstyleVersion}-all.jar`,
`node_modules/@jnxplus/tools/linters/ktlint/ktlint`
)
).not.toThrow();
}, 120000);

it('shoud works', async () => {
const name = uniq('app-');

await runNxCommandAsync(`generate @jnxplus/nx-gradle:app ${name}`);
}, 240000);
});
10 changes: 10 additions & 0 deletions testing-projects/e2e/nx-gradle-catalog-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.spec.json"
}
]
}
9 changes: 9 additions & 0 deletions testing-projects/e2e/nx-gradle-catalog-e2e/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"]
}

0 comments on commit f108119

Please sign in to comment.