-
-
Notifications
You must be signed in to change notification settings - Fork 34
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): make jar of
library
projects not executable
Moreover, we only add 'boot' related executors to `workspace.json` for `application` projects Closes #67
- Loading branch information
Showing
7 changed files
with
107 additions
and
18 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
29 changes: 29 additions & 0 deletions
29
packages/nx-spring-boot/src/generators/project/lib/disable-boot-jar-task.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,29 @@ | ||
import { | ||
logger, | ||
Tree | ||
} from '@nrwl/devkit'; | ||
import { NormalizedSchema } from '../schema'; | ||
|
||
export function disableBootJarTask(tree: Tree, options: NormalizedSchema) { | ||
if (options.projectType === 'library' && options.buildSystem === 'gradle-project') { | ||
logger.debug(`Disabling 'bootJar' task on a library project...`); | ||
|
||
const bootJarDisabledTask = ` | ||
// spring boot library projects don't need an executable jar, so we disable it | ||
bootJar { | ||
enabled = false | ||
} | ||
`; | ||
const jarEnabledTask = ` | ||
jar { | ||
enabled = true | ||
} | ||
`; | ||
const ext = options.language === 'kotlin' ? '.kts' : '' | ||
const buildGradlePath = `${options.projectRoot}/build.gradle${ext}`; | ||
let content = tree.read(buildGradlePath).toString(); | ||
|
||
content += bootJarDisabledTask + '\n' + jarEnabledTask; | ||
tree.write(buildGradlePath, content); | ||
} | ||
} |
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,6 @@ | ||
export { generateBootProject } from './generate-boot-project'; | ||
export { addPluginToNxJson } from './add-plugin-to-nx-json' | ||
export { addBuilInfoTask } from './add-build-info-task'; | ||
export { disableBootJarTask } from './disable-boot-jar-task'; | ||
export { removeBootMavenPlugin } from './remove-spring-boot-plugin'; | ||
export { normalizeOptions } from './normalize-options'; |
27 changes: 27 additions & 0 deletions
27
packages/nx-spring-boot/src/generators/project/lib/remove-spring-boot-plugin.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,27 @@ | ||
import { | ||
logger, | ||
Tree | ||
} from '@nrwl/devkit'; | ||
import { NormalizedSchema } from '../schema'; | ||
|
||
export function removeBootMavenPlugin(tree: Tree, options: NormalizedSchema) { | ||
if (options.projectType === 'library' && options.buildSystem === 'maven-project') { | ||
logger.debug(`Removing 'spring-boot' maven plugin on a library project...`); | ||
|
||
const mvnPlugin = ` | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
`; | ||
const pomXmlPath = `${options.projectRoot}/pom.xml`; | ||
let content = tree.read(pomXmlPath).toString(); | ||
|
||
content = content.replace(mvnPlugin, ''); | ||
tree.write(pomXmlPath, content); | ||
} | ||
} |