-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add makefile to spring boot qs #762
Open
stitakis
wants to merge
1
commit into
master
Choose a base branch
from
feature/allow-local-project-creation-qs-be-java-springboot
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
SHELL = /bin/bash | ||
.SHELLFLAGS := -eu -o pipefail -c | ||
.DELETE_ON_ERROR: | ||
MAKEFLAGS += --warn-undefined-variables | ||
MAKEFLAGS += --no-builtin-rules | ||
|
||
SOURCE_DIR=${sourceDir} | ||
TARGET_DIR=${targetDir} | ||
SPRING_BOOT_CLI_VERSION=${springBootVersion} | ||
PROJECT_ID=${projectId} | ||
COMPONENT_ID=${componentId} | ||
PACKAGE_NAME=${packageName} | ||
|
||
# create-project | ||
create-project: | ||
mkdir -p ${TARGET_DIR} | ||
cd ${TARGET_DIR} && curl https://start.spring.io/starter.tgz \ | ||
-d type=gradle-project \ | ||
-d language=java \ | ||
-d dependencies='web,jersey,data-jpa,h2,data-rest,restdocs,security' \ | ||
-d bootVersion=${SPRING_BOOT_CLI_VERSION} \ | ||
-d packaging=jar \ | ||
-d javaVersion=17 \ | ||
-d groupId=${PROJECT_ID} \ | ||
-d artifactId=${COMPONENT_ID} \ | ||
-d name=${COMPONENT_ID} \ | ||
-d description='OpenDevStack%20Demo%20Project%20for%20Spring%20Boot' \ | ||
-d packageName='${PACKAGE_NAME}' \ | ||
| tar -zxvf - | ||
|
||
.PHONY: create-project | ||
# add-sb-app-properties | ||
add-sb-app-properties: | ||
echo 'spring.profiles.active: dev' > ${TARGET_DIR}/src/main/resources/application.properties | ||
echo 'spring.jpa.database: HSQL' > ${TARGET_DIR}/src/main/resources/application-dev.properties | ||
.PHONY: add-sb-app-properties | ||
# customise-build-gradle | ||
customise-build-gradle: | ||
echo "called customise-build-gradle..." | ||
|
||
echo "...enforce minimal log4j2 version to avoid (CVE-2021-44228)" | ||
sed -i -e '/ext {/{r ${SOURCE_DIR}/templates/gradle-minimal-log4j2-version.template' -e 'd' -e '}' ${TARGET_DIR}/build.gradle | ||
|
||
echo "...add nexus credential settings" | ||
cat ${SOURCE_DIR}/templates/gradle-buildscript.template ${TARGET_DIR}/build.gradle >out && mv out ${TARGET_DIR}/build.gradle | ||
|
||
echo "...insert required plugins" | ||
sed -i -e '/plugins {/{r ${SOURCE_DIR}/templates/gradle-plugins.template' -e 'd' -e '}' ${TARGET_DIR}/build.gradle | ||
|
||
echo "...insert nexus repos" | ||
sed -i -e '/mavenCentral()/{r ${SOURCE_DIR}/templates/gradle-repositories.template' -e 'd' -e '}' ${TARGET_DIR}/build.gradle | ||
|
||
echo "...insert test settings" | ||
sed -i -e '/test {/{r ${SOURCE_DIR}/templates/gradle-plugin-test.template' -e 'd' -e '}' ${TARGET_DIR}/build.gradle | ||
|
||
echo "...append bootJar settings" | ||
cat ${SOURCE_DIR}/templates/gradle-plugin-bootjar.template >> ${TARGET_DIR}/build.gradle | ||
|
||
echo "...append jacoco settings" | ||
cat ${SOURCE_DIR}/templates/gradle-plugin-jacoco.template >> ${TARGET_DIR}/build.gradle | ||
|
||
echo "...append maven-publish settings" | ||
cat ${SOURCE_DIR}/templates/gradle-maven-publish.template >> ${TARGET_DIR}/build.gradle | ||
|
||
.PHONY: customise-build-gradle | ||
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for using this locally it would be nice to have an additional target that does all three existing targets in one, basically mimicking the jenkins stage where they are being called in.
And if you want to be fancy you could add a help target ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case you have no help target at hand, I used this code once in the past:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI I've switched to this short version lately: https://github.com/opendevstack/ods-pipeline/blob/master/Makefile#L15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool! but this does require having
awk
installed, no? Not every unix distro has it installed out of the box AFAIK.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, I think I'm mixing this up now with another unix tool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, I'll add this and also one target that calls all other.
@michaelsauter @renedupont do you think it might be worth to rename the target names to reflect some sort of standard targets/interface? Like create-project (calls all targets), create-project-template, update-project-template, etc...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes why not
you only have to come up with names that fit all quickstarters :)
It is already hard for this qs here - if I see it right you would rename the current create-project target into create-project-template, but from my point of view what is actually happening in their is not a creation of a template but rather the initialization of the project (the service is calles spring initializr).