Skip to content

Instantly share code, notes, and snippets.

@paulbrodner
Last active August 20, 2021 10:53
Show Gist options
  • Select an option

  • Save paulbrodner/c4becf42a1541effd9db5910c6e51b07 to your computer and use it in GitHub Desktop.

Select an option

Save paulbrodner/c4becf42a1541effd9db5910c6e51b07 to your computer and use it in GitHub Desktop.
Makefile example
help: ## debian
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep
help: ## output this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?##|[a-zA-Z_-]\.?+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help
bamboo_JAVA_HOME ?= /opt/jdk-11 # default to java11 if not set
ifeq ($(SERVER),)
SERVER := cd acs && docker-compose
endif
ifeq ($(MVN),)
ifeq ($(bamboo_working_directory),)
MVN := mvn
else
# on bamboo environment define the environment
export M2_HOME=
MVN:=/opt/maven-3.3/bin/mvn
export JAVA_HOME=$(bamboo_JAVA_HOME)
endif
endif
export GIT_AUTHOR_NAME=bamboo_auth
export GIT_AUTHOR_EMAIL=bamboo_auth@internal.alfresco.com
export GIT_COMMITTER_NAME=bamboo_auth
export GIT_COMMITTER_EMAIL=bamboo_auth@internal.alfresco.com
compile:
$(MVN) --version && $(MVN) --batch-mode compile -U -DskipTests
test:
$(MVN) --batch-mode test -DsuiteXmlFile=src/main/resources/tas-demo-suite.xml
release: ## perform the release, automatically increase the version
$(MVN) --batch-mode release:prepare release:perform \
-Dmaven.javadoc.skip=true \
-Dresume=false \
-Dusername=$(GIT_COMMITTER_NAME) \
-Dpassword=$(bamboo_auth_ldap_password) \
"-Darguments=-Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Dadditionalparam=-Xdoclint:none"
acs-up: ## will install ACS with docker-compose according to profile
$(SERVER) config
$(SERVER) up -d
./acs/wait-service-to-start.sh
acs-down: ## will stop ACS docker-compose according to profile
$(SERVER) kill
$(SERVER) rm -fv
acs-logs: ## show logs
$(SERVER) logs -f
#-----------------------
define HEADER
__ __
/ \\..// \
( oo )
\__/
endef
export HEADER
build:
@echo "$$HEADER"
#-----------------------
### multilines
test:
@( \
echo echo I Need This ;\
echo echo To Work ;\
) \
| sh
define script
cat <<EOF > test.json
{
"type": "GITHUB",
"location": "https://github.com/paulbrodner/jokes",
"gitCloneDepth": 1,
"gitSubmodulesConfig": {
"fetchSubmodules": false
},
"buildspec": "buildspec.yml",
"auth": {
"type": "OAUTH",
"resource": "arn:aws:codebuild:eu-west-1:sdsd21:token/github"
},
"reportBuildStatus": true,
"insecureSsl": false,
"sourceIdentifier": "jokes"
}
EOF
endef
test:
eval "$$script"
---------------------
VERSION :=$(shell grep \<version pom.xml |awk '{ if(NR==2) print $$0 }' | awk -F '[><]' '{print $$3}')
.PHONY: tree
help: ## output this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?##|[a-zA-Z_-]\.?+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
#export MAVEN_OPTS=-Dorg.slf4j.simpleLogger.defaultLogLevel=warn &&
install: ## build keycloak
mvn clean install -nsu -s maven-settings.xml \
-Pdistribution \
-Dmaven.test.skip \
-DskipTestsuite \
-DskipTests
build-server: ## build only the keycloack server distribution zip
mvn -Pdistribution \
-pl distribution/server-dist \
-am \
-Dmaven.test.skip \
clean install
start-server: ## start server from distribution (run build-server if not done already)
cd distribution/server-dist/target/ && \
unzip -oq keycloak-$(VERSION).zip && \
cd keycloak-$(VERSION) && \
bash bin/standalone.sh
tree: ## analyze the dependencies and produce a report
mvn dependency:tree -Dverbose > tree.txt
version: ## display current version
@echo $(VERSION)
scan: ## scan the distribution
@[ -f wss-unified-agent.jar ] && echo "wss-unified-agent.jar exist" || curl -LJO https://github.com/whitesource/unified-agent-distribution/releases/latest/download/wss-unified-agent.jar
@[ -f wss-unified-agent.config ] && echo "wss-unified-agent.config exist" || curl -LJO https://github.com/whitesource/unified-agent-distribution/raw/master/standAlone/wss-unified-agent.config
java -jar wss-unified-agent.jar \
-d distribution/server-dist/target/keycloak-$(VERSION) \
-product "Alfresco Identity Service" \
-project "Identity Service" \
-projectVersion "local-$(VERSION)"
confirm-namespace:
ifndef SKIP_CONFIRM
@echo The next actions will be applied to namespace: $(NAMESPACE)
@echo "Are you sure you want to continue ? [y/n] (y - default) " && read ans && [ $${ans:-y} == y ]
else
@echo Skipping confirmation for namespace: $(NAMESPACE)
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment