Skip to content
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

Fixes #11611: Port helloworld & datasource to use common-scala-plugin.mk #2

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions common-scala-plugin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ target/scripts.txz:

target/metadata: prepare-files
cp packaging/metadata target/metadata
sed -i -e "s/\$${plugin-id}/$(FULL_NAME)/" target/metadata
sed -i -e "s/\$${plugin-version}/$(VERSION)/" target/metadata
sed -i -e "s/\$${maven.build.timestamp}/$(BUILD_TIMESTAMP)/" target/metadata
sed -i -e "s/\$${commit-id}/$(COMMIT_ID)/" target/metadata
sed -i -e "s/\$${plugin-id}/$(FULL_NAME)/g" target/metadata
sed -i -e "s/\$${plugin-version}/$(VERSION)/g" target/metadata
sed -i -e "s/\$${maven.build.timestamp}/$(BUILD_TIMESTAMP)/g" target/metadata
sed -i -e "s/\$${commit-id}/$(COMMIT_ID)/g" target/metadata
sed -i -e "s/\$${plugin-name}/$(NAME)/g" target/metadata

# plugin-resources must be implemented for each plugin.
# the goal is to copy the plugin needed resources into target/$(NAME)
Expand Down
68 changes: 5 additions & 63 deletions datasources/Makefile
Original file line number Diff line number Diff line change
@@ -1,71 +1,13 @@
#
# make all will build datasources.rpkg.
# make all will build node-external-reports.rpkg.
# make demo will build a license limited version of the plugin
#

RUDDER_BRANCH = $(shell sed -ne '/^rudder-branch=/s/rudder-branch=//p' build.conf)
PLUGIN_BRANCH = $(shell sed -ne '/^plugin-branch=/s/plugin-branch=//p' build.conf)
VERSION = $(RUDDER_BRANCH)-$(PLUGIN_BRANCH)
FULL_NAME = $(shell sed -ne '/^plugin-id=/s/plugin-id=//p' build.conf)
NAME = $(shell echo $(FULL_NAME) | sed -ne 's/rudder-plugin-//p')
MAVEN_OPTS = --batch-mode -U
include ../common-scala-plugin.mk

## for demo
# standard destination path for the license file is in module directory, "license.sign"
TARGET_LICENSE_PATH = /opt/rudder/share/plugins/$(NAME)/license
# standard destination path for the key is at JAR root, name: license.pubkey
TARGET_KEY_CLASSPATH = license.pubkey
# SIGNED_LICENSE_PATH: path towards the license file to embed
# PUBLIC_KEY_PATH: path towards the public key to embed
plugin: all

# build the default oss version of the package
all: std-files $(FULL_NAME)-$(VERSION).rpkg
plugin-resources:
cp ./src/main/resources/datasources-schema.sql target/$(NAME)/

# build a "demo" version of the plugin, limited by a license file and verified by a public key
demo: demo-files $(FULL_NAME)-$(VERSION).rpkg

clean:
rm -f scripts.txz files.txz $(FULL_NAME)-$(VERSION).rpkg
rm -rf target $(NAME)

scripts.txz:
tar cJ -C packaging -f scripts.txz postinst

$(FULL_NAME)-$(VERSION).rpkg:
ar r $(FULL_NAME)-$(VERSION).rpkg target/metadata files.txz scripts.txz

target/metadata:
mvn $(MAVEN_OPTS) $(DEMO) -Dcommit-id=$$(git rev-parse HEAD 2>/dev/null || true) properties:read-project-properties resources:copy-resources@copy-metadata

std-files: common-files std-jar prepare-files files.txz

demo-files: common-files check-demo demo-jar prepare-files add-license files.txz

common-files: target/metadata scripts.txz

check-demo:
test -n "$(SIGNED_LICENSE_PATH)" # $$SIGNED_LICENSE_PATH must be defined
test -n "$(PUBLIC_KEY_PATH)" # $$PUBLIC_KEY_PATH must be defined

files.txz:
tar cJ -f files.txz $(NAME)

prepare-files:
mkdir -p $(NAME)
cp ./src/main/resources/datasources-schema.sql $(NAME)/
cp target/$(NAME).jar $(NAME)/

add-license:
# embed license file since we are in demo limited build
cp $(SIGNED_LICENSE_PATH) $(NAME)/license

std-jar:
mvn $(MAVEN_OPTS) package
mv target/datasources-*-plugin-with-own-dependencies.jar target/$(NAME).jar

demo-jar:
mvn $(MAVEN_OPTS) -Dlimited -Dplugin-resource-publickey=$(TARGET_KEY_CLASSPATH) -Dplugin-resource-license=$(TARGET_LICENSE_PATH) -Dplugin-declared-version=$(VERSION) package
mv target/datasources-*-plugin-with-own-dependencies.jar target/$(NAME).jar
cp $(PUBLIC_KEY_PATH) target/$(TARGET_KEY_CLASSPATH)
jar -uf target/$(NAME).jar -C target $(TARGET_KEY_CLASSPATH)

2 changes: 1 addition & 1 deletion datasources/packaging/metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "${plugin-version}",
"build-date": "${maven.build.timestamp}",
"build-commit": "${commit-id}",
"jar-files": [ "/opt/rudder/share/plugins/datasources/datasources.jar" ],
"jar-files": [ "/opt/rudder/share/plugins/${plugin-name}/${plugin-name}.jar" ],
"content": {
"files.txz": "/opt/rudder/share/plugins"
}
Expand Down
16 changes: 16 additions & 0 deletions helloworld/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# make all will build node-external-reports.rpkg.
# make demo will build a license limited version of the plugin
#

include ../common-scala-plugin.mk

plugin: all

# this plugin has no resources to install
plugin-resources:
# nothing to cp into target$(NAME)
# example could be:
#cp src/main/resources/helloworld.properties target/$(NAME)/


26 changes: 26 additions & 0 deletions helloworld/build.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# This file defines the release information about the plugin like
# its version and its ABI compability.
#
# So version are not managed in pom.xml (safe for parent-pom version,
# which can't be a parameter, and must be equals to rudder-branch here)
#

# Unique identifier of the plugin
plugin-id=rudder-plugin-helloworld
# Human readable name
plugin-name=An example plugin for Rudder

# Plugin version. It is build as follow: A.B-x.y(.z) with:
# - A.B: Rudder major.minor
# - x.y(.z): plugin major.minor.micro. Micro should be omitted. When omitted, z is assumed to be 0.
# For the build, we split the information between two properties, rudder branch and plugin version,
# which must be concaneted with "-" to build the plugin version.
rudder-branch=4.1
plugin-branch=1.1
plugin-version=${rudder-branch}-${plugin-branch}

# Version of Rudder used to build the plugin.
# It defined the API/ABI used and it is important for binary compatibility
#
rudder-build-version=4.1.0
Empty file.
Empty file.
1 change: 0 additions & 1 deletion helloworld/packaging/SOURCES/.dependencies

This file was deleted.

61 changes: 0 additions & 61 deletions helloworld/packaging/SOURCES/Makefile

This file was deleted.

5 changes: 0 additions & 5 deletions helloworld/packaging/SOURCES/settings-external.xml

This file was deleted.

16 changes: 0 additions & 16 deletions helloworld/packaging/SOURCES/settings-internal.xml

This file was deleted.

132 changes: 0 additions & 132 deletions helloworld/packaging/SPECS/rudder-plugin-helloworld.spec

This file was deleted.

Empty file.
6 changes: 0 additions & 6 deletions helloworld/packaging/debian/README

This file was deleted.

5 changes: 0 additions & 5 deletions helloworld/packaging/debian/changelog

This file was deleted.

1 change: 0 additions & 1 deletion helloworld/packaging/debian/compat

This file was deleted.

Empty file.
17 changes: 0 additions & 17 deletions helloworld/packaging/debian/control

This file was deleted.

Loading