package/maven-bin: new package
PATCH 1/1 package/maven-bin: new package
From: Adam Duskett <[email protected]>
Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting, and documentation from a central piece of information.
As Maven requires Maven to build, and the Apache foundation provides a self-encompassing tarball with Maven already compiled, it is much easier to treat this package much like we do with host-openjdk-bin.
Traditionally, Maven's installation directory is either usr/share/maven or /usr/lib/maven with the mvn binary symlinked to /usr/bin. This installation method keeps all of the various libraries and conf files provided in the maven tarball separated from the rest of the host directory and prevents any libraries from potentially overwriting previously installed host-package libraries.
By default, Maven downloads dependency modules of a given package to ~/.m2, which goes against Buildroot being a sandbox.
There are two options to change this path:
1) Hardcode a path in the provided settings.xml file to the desired location.
2) Set the path to a variable and pass the path via to Maven during runtime.
Option 2 has the advantage of ensuring all the paths are relocatable.
Instead of using sed on the provided settings.xml, which would be very difficult to do, as the default settings file has the localRepository variable commented out, a settings.xml file in package/maven-bin has the localRepository variable pre-set to the MAVEN_REPO_DIR environment variable.
Finally, maven-bin.mk provides the MAVEN environment variable helper, which provides all of the needed variables needed to invoke Maven in a single command, making it much easier to integrate packages that need to use Maven.
An example of using Maven with a package would be as such:
FOO_DEPENDENCIES = host-maven-bin
define FOO_BUILD_CMDS
cd $(@D) && $(MAVEN) compile
endef
define FOO_INSTALL_TARGET_CMDS
$(INSTALL) -m 755 $(@D)/target/foo.jar $(TARGET_DIR)/usr/bin/foo.jar
endef
--- DEVELOPERS | 1 + package/maven-bin/Config.in | 13 +++++++ package/maven-bin/maven-bin.hash | 3 ++ package/maven-bin/maven-bin.mk | 36 +++++++++++++++++++ package/maven-bin/settings.xml | 61 ++++++++++++++++++++++++++++++++ 5 files changed, 114 insertions(+) create mode 100644 package/maven-bin/Config.in create mode 100644 package/maven-bin/maven-bin.hash create mode 100644 package/maven-bin/maven-bin.mk create mode 100644 package/maven-bin/settings.xml
DEVELOPERS +1 -0
@@ -50,6 +50,7 @@ F: package/libsemanage/ F: package/libsepol/ F: package/libtextstyle/ F: package/libwebsockets/ +F: package/maven-bin/ F: package/mender-grubenv/ F: package/nginx-naxsi/ F: package/openjdk/
package/maven-bin/Config.in new file +13 -0
@@ -0,0 +1,13 @@ +config BR2_PACKAGE_MAVEN_BIN + bool "maven-bin" + depends on BR2_PACKAGE_OPENJDK + help + Apache Maven is a software project management and + comprehension tool. Based on the concept of a project object + model (POM), Maven can manage a project's build, reporting and + documentation from a central piece of information. + + https://github.com/apache/maven + +comment "maven-bin needs openjdk" + depends on !BR2_PACKAGE_OPENJDK
package/maven-bin/maven-bin.hash new file +3 -0
@@ -0,0 +1,3 @@ +# Locally computed +sha256 26ad91d751b3a9a53087aefa743f4e16a17741d3915b219cf74112bf87a438c5 apache-maven-3.6.3-bin.tar.gz +sha256 8b79d3d26bfbfd31fc50b22b149c2ecd2863345abb62d15048157a6f2e774411 LICENSE
package/maven-bin/maven-bin.mk new file +36 -0
@@ -0,0 +1,36 @@ +################################################################################ +# +# host-maven-bin +# +################################################################################ + +HOST_MAVEN_BIN_VERSION = 3.6.3 +HOST_MAVEN_BIN_SOURCE = apache-maven-$(HOST_MAVEN_BIN_VERSION)-bin.tar.gz +HOST_MAVEN_BIN_SITE = https://www-us.apache.org/dist/maven/maven-3/$(HOST_MAVEN_BIN_VERSION)/binaries +HOST_MAVEN_BIN_LICENSE = Apache-2.0 +HOST_MAVEN_BIN_LICENSE_FILES = LICENSE +HOST_MAVEN_BIN_DEPENDENCIES = host-openjdk-bin + +# Maven is traditionally installed in it's own seperate directory in either +# usr/share/maven or /usr/lib/maven with the mvn binary symlinked to /usr/bin. +define HOST_MAVEN_BIN_INSTALL_CMDS + mkdir -p $(HOST_DIR)/usr/lib/maven + mkdir -p $(HOST_DIR)/bin + cp -dprf $(@D)/* $(HOST_DIR)/usr/lib/maven/ + ln -sf $(HOST_DIR)/usr/lib/maven/bin/mvn $(HOST_DIR)/bin/mvn + +# The settings.xml file sets the localRepository directory to the +# MAVEN_REPO_DIR environment variable. + $(INSTALL) -D -m 755 $(HOST_MAVEN_BIN_PKGDIR)/settings.xml \ + $(HOST_DIR)/usr/lib/maven/conf/settings.xml +endef + +$(eval $(host-generic-package)) + +# variables used by other packages +MAVEN = \ + JAVA_HOME="$(HOST_DIR)/usr/lib/jvm" \ + M2_HOME="$(HOST_DIR)/usr/lib/maven" \ + MAVEN_HOME="$(HOST_DIR)/usr/lib/maven" \ + MAVEN_REPO_DIR="$(BR2_DL_DIR)/maven-repo" \ + $(HOST_DIR)/bin/mvn
package/maven-bin/settings.xml new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 1/1 package/maven-bin: new package
Hello,
Quoted 14 lines · On Thu, 18 Jun 2020 12:43:27 -0700 aduskett at gmail.com wrote:
Instead of using sed on the provided settings.xml, which would be very difficult to do, as the default settings file has the localRepository variable commented out, a settings.xml file in package/maven-bin has the localRepository variable pre-set to the
MAVEN_REPO_DIRenvironment variable.Finally, maven-bin.mk provides the MAVEN environment variable helper, which provides all of the needed variables needed to invoke Maven in a single command, making it much easier to integrate packages that need to use Maven.
An example of using Maven with a package would be as such:
FOO_DEPENDENCIES= host-maven-bindefine
FOO_BUILD_CMDS
Quoted 8 lines
cd $(@D) && $(MAVEN) compileendef
define
FOO_INSTALL_TARGET_CMDS$(INSTALL) -m 755 $(@D)/target/foo.jar $(TARGET_DIR)/usr/bin/foo.jarendef
Signed-off-by Adam Duskett <[email protected]>
Thanks for this contribution. Do you have a package that needs this and that you intend to contribute to Buildroot ? It's always a bit annoying to have host packages that are not used by anything.
Or is there at least some stupid package we could throw into a br2-external in support/testing and have a runtime test case that builds it with Maven ?
Quoted 9 lines
package/maven-bin/Config.in new file +3
-0@@ -0,0 +1,13 @@ +config BR2_PACKAGE_MAVEN_BIN + bool "maven-bin" + depends on BR2_PACKAGE_OPENJDK
package/maven-bin/Config.in line 13
Quoted 10 lines
package/maven-bin/Config.in new file +10
-0+ help + Apache Maven is a software project management and + comprehension tool. Based on the concept of a project object + model (POM), Maven can manage a project's build, reporting and + documentation from a central piece of information. + + https://github.com/apache/maven + +comment "maven-bin needs openjdk" + depends on !BR2_PACKAGE_OPENJDK
Why do you have a Config.in option to enable a target package that doesn't exist, since there's no maven-bin package, only host-maven-bin ?
Quoted 15 lines
package/maven-bin/maven-bin.hash new file +3
-0@@ -0,0 +1,3 @@ +# Locally computed +sha256 26ad91d751b3a9a53087aefa743f4e16a17741d3915b219cf74112bf87a438c5 apache-maven-3.6.3-bin.tar.gz +sha256 8b79d3d26bfbfd31fc50b22b149c2ecd2863345abb62d15048157a6f2e774411 LICENSEpackage/maven-bin/maven-bin.mk new file +0
-0
package/maven-bin/maven-bin.mk line 3
Quoted 3 lines
package/maven-bin/maven-bin.mk new file +3
-0@@ -0,0 +1,36 @@ +################################################################################ +# +# host-maven-bin
Just maven-bin
package/maven-bin/maven-bin.mk line 11
Quoted 8 lines
package/maven-bin/maven-bin.mk new file +8
-0+# +################################################################################ + +HOST_MAVEN_BIN_VERSION = 3.6.3 +HOST_MAVEN_BIN_SOURCE = apache-maven-$(HOST_MAVEN_BIN_VERSION)-bin.tar.gz +HOST_MAVEN_BIN_SITE = https://www-us.apache.org/dist/maven/maven-3/$(HOST_MAVEN_BIN_VERSION)/binaries +HOST_MAVEN_BIN_LICENSE = Apache-2.0 +HOST_MAVEN_BIN_LICENSE_FILES = LICENSE
Please use:
MAVEN_BIN_xyz
for all those variables. I know there's no target variant, but there's no need to have a HOST_ prefix for those variables.
package/maven-bin/maven-bin.mk line 14
Quoted 3 lines
package/maven-bin/maven-bin.mk new file +3
-0+HOST_MAVEN_BIN_DEPENDENCIES = host-openjdk-bin + +# Maven is traditionally installed in it's own seperate directory in either
seperate -> separate
Quoted 11 lines
package/maven-bin/maven-bin.mk new file +11
-0+# usr/share/maven or /usr/lib/maven with the mvn binary symlinked to /usr/bin. +define HOST_MAVEN_BIN_INSTALL_CMDS + mkdir -p $(HOST_DIR)/usr/lib/maven + mkdir -p $(HOST_DIR)/bin + cp -dprf $(@D)/* $(HOST_DIR)/usr/lib/maven/ + ln -sf $(HOST_DIR)/usr/lib/maven/bin/mvn $(HOST_DIR)/bin/mvn + +# The settings.xml file sets the localRepository directory to the +# MAVEN_REPO_DIR environment variable. + $(INSTALL) -D -m 755 $(HOST_MAVEN_BIN_PKGDIR)/settings.xml \ + $(HOST_DIR)/usr/lib/maven/conf/settings.xml
package/maven-bin/maven-bin.mk line 35
Quoted 10 lines
package/maven-bin/maven-bin.mk new file +10
-0+endef + +$(eval $(host-generic-package)) + +# variables used by other packages +MAVEN = \ + JAVA_HOME="$(HOST_DIR)/usr/lib/jvm" \ + M2_HOME="$(HOST_DIR)/usr/lib/maven" \ + MAVEN_HOME="$(HOST_DIR)/usr/lib/maven" \ + MAVEN_REPO_DIR="$(BR2_DL_DIR)/maven-repo" \
This is not really going to solve the problem that maven works around the Buildroot download infrastructure, if it downloads things by itself. What is the plan regarding this ?
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com