-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nx-spring-boot): add
install
executor + make build
depend on it
This executor publishes project's artifacts (i.e jar file) to local Maven repository (`~/.m2/repository`). This allows dependant projects to properly resolve the dependency during their on build. Besides, a task dependency was added to `build` executor, so that Nx will automatically call this `install` executor on dependencies, when running the `build` task from the dependant project, meaning you don't have to worry about it. Closes #65, #66 and #71
- Loading branch information
Showing
11 changed files
with
214 additions
and
41 deletions.
There are no files selected for viewing
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
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
47 changes: 47 additions & 0 deletions
47
packages/nx-spring-boot/src/executors/install/executor.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,47 @@ | ||
import { logger } from '@nrwl/devkit'; | ||
import { mocked } from 'jest-mock'; | ||
|
||
import { installExecutor } from './executor'; | ||
import { InstallExecutorOptions } from './schema'; | ||
import { GRADLE_WRAPPER_EXECUTABLE, MAVEN_WRAPPER_EXECUTABLE, NX_SPRING_BOOT_PKG } from '@nxrocks/common'; | ||
import { expectExecutorCommandRanWith, mockExecutorContext } from '@nxrocks/common/testing'; | ||
|
||
//first, we mock | ||
jest.mock('child_process'); | ||
jest.mock('@nrwl/workspace/src/utils/fileutils'); | ||
|
||
//then, we import | ||
import * as fsUtility from '@nrwl/workspace/src/utils/fileutils'; | ||
import * as cp from 'child_process'; | ||
|
||
const mockContext = mockExecutorContext(NX_SPRING_BOOT_PKG, 'install'); | ||
const options: InstallExecutorOptions = { | ||
root: 'apps/bootapp' | ||
}; | ||
|
||
describe('Install Executor', () => { | ||
|
||
beforeEach(async () => { | ||
jest.spyOn(logger, 'info'); | ||
jest.spyOn(cp, 'execSync'); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
it.each` | ||
ignoreWrapper | buildSystem | buildFile | execute | ||
${true} | ${'maven'} | ${'pom.xml'} | ${'mvn install '} | ||
${true} | ${'gradle'} | ${'build.gradle'} | ${'gradle publishToMavenLocal '} | ||
${false} | ${'maven'} | ${'pom.xml'} | ${MAVEN_WRAPPER_EXECUTABLE + ' install '} | ||
${false} | ${'gradle'} | ${'build.gradle'} | ${GRADLE_WRAPPER_EXECUTABLE + ' publishToMavenLocal '} | ||
`('should execute a $buildSystem build and ignoring wrapper : $ignoreWrapper', async ({ ignoreWrapper, buildFile, execute }) => { | ||
mocked(fsUtility.fileExists).mockImplementation((filePath: string) => filePath.indexOf(buildFile) !== -1); | ||
|
||
await installExecutor({ ...options, ignoreWrapper }, mockContext); | ||
|
||
expectExecutorCommandRanWith(execute, mockContext, options); | ||
}); | ||
|
||
}); |
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,11 @@ | ||
import { ExecutorContext } from '@nrwl/devkit' | ||
import * as path from 'path' | ||
import { InstallExecutorOptions } from './schema' | ||
import { runBootPluginCommand } from '../../utils/boot-utils' | ||
|
||
export async function installExecutor(options: InstallExecutorOptions, context: ExecutorContext){ | ||
const root = path.resolve(context.root, options.root); | ||
return runBootPluginCommand('install', options.args, { cwd : root, ignoreWrapper: options.ignoreWrapper}); | ||
} | ||
|
||
export default installExecutor; |
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,6 @@ | ||
|
||
export interface InstallExecutorOptions { | ||
root: string; | ||
ignoreWrapper?: boolean; | ||
args?: string[]; | ||
} |
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,24 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"title": "Install executor", | ||
"description": "", | ||
"cli": "nx", | ||
"type": "object", | ||
"properties": { | ||
"root": { | ||
"description": "The project root", | ||
"type": "string" | ||
}, | ||
"ignoreWrapper": { | ||
"description": "Whether or not to use the embedded wrapper (`mvnw`or `gradlew`) to perfom build operations", | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"args": { | ||
"description": "The argument to be passed to the underlying Spring Boot command", | ||
"type": "array", | ||
"default": [] | ||
} | ||
}, | ||
"required": [] | ||
} |
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
Oops, something went wrong.