Skip to content

Commit

Permalink
Fixes #11758: Separate scala plugin makefiles from generic plugin mak…
Browse files Browse the repository at this point in the history
…efiles
  • Loading branch information
peckpeck committed Nov 24, 2017
1 parent 45b8bb5 commit 3399fb4
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 97 deletions.
80 changes: 0 additions & 80 deletions common-scala-plugin.mk

This file was deleted.

11 changes: 5 additions & 6 deletions datasources/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#
# make all will build node-external-reports.rpkg.
# make demo will build a license limited version of the plugin
# make all : will build node-external-reports.rpkg.
# make licensed : will build a license limited version of the plugin
#

include ../common-scala-plugin.mk
include ../makefiles/common-scala-plugin.mk

plugin: all
FILES += $(NAME)/datasources-schema.sql

plugin-resources:
target/$(NAME)/datasources-schema.sql:
cp ./src/main/resources/datasources-schema.sql target/$(NAME)/


26 changes: 18 additions & 8 deletions helloworld/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
#
# make all will build node-external-reports.rpkg.
# make demo will build a license limited version of the plugin
# make all : will build helloworld.rpkg.
# make license : will build a license limited version of the plugin
#

include ../common-scala-plugin.mk
# Use this one for a Scala plugin
include ../makefiles/common-scala-plugin.mk

plugin: all
# Uncomment this one for a non scala plugin
#include ../makefiles/common-plugin.mk

# this plugin has no resources to install
plugin-resources:
# nothing to cp into target$(NAME)
# example could be:
# Uncomment to add files to include in the plugin's main directory
# Those files are relative to the target/ directory
#FILES += $(NAME)/helloworld.properties
#target/$(NAME)/helloworld.properties:
#cp src/main/resources/helloworld.properties target/$(NAME)/

# Uncomment to add scripts to the plugin (default is to have only postinst)
# Those files are relative to the packaging directory
#SCRIPTS += preinst

# Add another archive to the plugin (files.txz is the first one)
#OTHER_ARCHIVES += target/other.txz
#target/other.txz:
#tar cJ -C packaging -f target/other.txz file1 file2

12 changes: 12 additions & 0 deletions makefiles/common-plugin.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Common make directives for all plugins not based on a jar.
# make all : will build $(NAME).rpkg.
# make licensed : is not yet supported
#

include ../makefiles/common.mk

std-files:

licensed-files:
echo "License not supported for this kind of plugin" && /bin/false

39 changes: 39 additions & 0 deletions makefiles/common-scala-plugin.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Common make directives for all plugins based on a jar.
# make all : will build $(NAME).rpkg.
# make licensed : will build a license limited version of the plugin
#

include ../makefiles/common.mk

MAVEN_OPTS = --batch-mode -U

## For licensed plugins
# 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

# Files to add to the plugin content (from the target directory)
# By default this is a directory containing the plugin jar
FILES = $(NAME)

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

licensed-files: check-license
mvn $(MAVEN_OPTS) -Dlimited -Dplugin-resource-publickey=$(TARGET_KEY_CLASSPATH) -Dplugin-resource-license=$(TARGET_LICENSE_PATH) -Dplugin-declared-version=$(VERSION) package
mkdir -p target/$(NAME)
mv target/$(NAME)-*-plugin-with-own-dependencies.jar target/$(NAME)/$(NAME).jar
jar -uf target/$(NAME)/$(NAME).jar -C target $(TARGET_KEY_CLASSPATH)
# embed the license
cp $(SIGNED_LICENSE_PATH) target/$(NAME)/license

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

.PHONY: std-files licensed-files check-license
51 changes: 51 additions & 0 deletions makefiles/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Common make directives for all plugins based on a jar.
# make all will build $(NAME).rpkg.
# make licensed will build a license limited version of the plugin
#

.DEFAULT_GOAL := all

# Available variables for override from makefiles
OTHER_ARCHIVES =
SCRIPTS = postinst
FILES =

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')
COMMIT_ID = $(shell git rev-parse HEAD 2>/dev/null || true)
BUILD_TIMESTAMP = $(shell date --iso-8601=seconds)

# build the default oss version of the package
all: std-files $(FULL_NAME)-$(VERSION).rpkg

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

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

target/scripts.txz: $(addprefix packaging/,$(SCRIPTS))
tar cJ -C packaging -f target/scripts.txz $(SCRIPTS)

target/files.txz: $(addprefix target/,$(FILES))
test [ -n "$(FILES)" ] # you must define the FILES variable in your Makefile
tar cJ -C target -f target/files.txz $(FILES)

target/metadata:
mkdir -p target
cp packaging/metadata 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

clean:
rm -f $(FULL_NAME)-$(VERSION).rpkg
rm -rf target


.PHONY: all licensed clean std-files licensed-files
5 changes: 2 additions & 3 deletions node-external-reports/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ include ../common-scala-plugin.mk

CONFIG_FILE_PATH = src/main/resources/node-external-reports.properties

plugin: all
FILES += $(NAME)/$(CONFIG_FILE_PATH)

plugin-resources:
target/$(NAME)/$(CONFIG_FILE_PATH)
cp $(CONFIG_FILE_PATH) target/$(NAME)/


0 comments on commit 3399fb4

Please sign in to comment.