-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gradle): support composite build
- Loading branch information
Showing
15 changed files
with
435 additions
and
69 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip | ||
validateDistributionUrl=false | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
{ | ||
"generators": {}, | ||
"generators": { | ||
"add-project-report-all": { | ||
"version": "19.3.0-beta.4", | ||
"cli": "nx", | ||
"description": "Add task projectReportAll to build.gradle file", | ||
"factory": "./src/migrations/19-3-0/add-project-report-all" | ||
} | ||
}, | ||
"packageJsonUpdates": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import json = require('./migrations.json'); | ||
|
||
import { assertValidMigrationPaths } from '@nx/devkit/internal-testing-utils'; | ||
import { MigrationsJson } from '@nx/devkit'; | ||
|
||
describe('gradle migrations', () => { | ||
assertValidMigrationPaths(json as MigrationsJson, __dirname); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/gradle/src/migrations/19-3-0/add-project-report-all.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; | ||
import { Tree } from '@nx/devkit'; | ||
|
||
import update from './add-project-report-all'; | ||
|
||
describe('AddProjectReportAll', () => { | ||
let tree: Tree; | ||
|
||
beforeAll(() => { | ||
tree = createTreeWithEmptyWorkspace(); | ||
}); | ||
|
||
it('should update build.gradle', async () => { | ||
tree.write('settings.gradle', ''); | ||
await update(tree); | ||
const buildGradle = tree.read('build.gradle').toString(); | ||
expect(buildGradle).toContain('project-report'); | ||
expect(buildGradle).toContain('projectReportAll'); | ||
}); | ||
|
||
it('should update build.gradle.kts', async () => { | ||
tree.write('settings.gradle.kts', ''); | ||
await update(tree); | ||
const buildGradle = tree.read('build.gradle.kts').toString(); | ||
expect(buildGradle).toContain('project-report'); | ||
expect(buildGradle).toContain('projectReportAll'); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/gradle/src/migrations/19-3-0/add-project-report-all.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Tree } from '@nx/devkit'; | ||
import { addBuildGradleFileNextToSettingsGradle } from '../../generators/init/init'; | ||
|
||
/** | ||
* This migration adds task `projectReportAll` to build.gradle files | ||
*/ | ||
export default async function update(tree: Tree) { | ||
await addBuildGradleFileNextToSettingsGradle(tree); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { join } from 'path'; | ||
import { processGradleDependencies } from './dependencies'; | ||
|
||
jest.mock('@nx/devkit', () => ({ | ||
...jest.requireActual<any>('@nx/devkit'), | ||
validateDependency: jest.fn().mockReturnValue(true), | ||
})); | ||
|
||
describe('processGradleDependencies', () => { | ||
it('should process gradle dependencies with composite build', () => { | ||
const depFilePath = join( | ||
__dirname, | ||
'..', | ||
'utils/__mocks__/gradle-composite-dependencies.txt' | ||
); | ||
const dependencies = new Set([]); | ||
processGradleDependencies( | ||
depFilePath, | ||
new Map([ | ||
[':my-utils:number-utils', 'number-utils'], | ||
[':my-utils:string-utils', 'string-utils'], | ||
]), | ||
'app', | ||
'app', | ||
{} as any, | ||
dependencies | ||
); | ||
expect(Array.from(dependencies)).toEqual([ | ||
{ | ||
source: 'app', | ||
sourceFile: 'app', | ||
target: 'number-utils', | ||
type: 'static', | ||
}, | ||
{ | ||
source: 'app', | ||
sourceFile: 'app', | ||
target: 'string-utils', | ||
type: 'static', | ||
}, | ||
]); | ||
}); | ||
|
||
it('should process gradle dependencies with regular build', () => { | ||
const depFilePath = join( | ||
__dirname, | ||
'..', | ||
'utils/__mocks__/gradle-dependencies.txt' | ||
); | ||
const dependencies = new Set([]); | ||
processGradleDependencies( | ||
depFilePath, | ||
new Map([ | ||
[':my-utils:number-utils', 'number-utils'], | ||
[':my-utils:string-utils', 'string-utils'], | ||
[':utilities', 'utilities'], | ||
]), | ||
'app', | ||
'app', | ||
{} as any, | ||
dependencies | ||
); | ||
expect(Array.from(dependencies)).toEqual([ | ||
{ | ||
source: 'app', | ||
sourceFile: 'app', | ||
target: 'utilities', | ||
type: 'static', | ||
}, | ||
]); | ||
}); | ||
}); |
Oops, something went wrong.