2 # Copyright (C) 2021 Michael Zucchi
4 # This is the copyright for maven.make
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # This lets one download maven packages using simple automake syntax.
22 # maven_<name>_URL = baseurl
24 # Define the base url. maven_central_URL is already defined as
25 # maven_central_URL:=https://repo1.maven.org/maven2
27 # maven_<name>_JARS = group:artifact:version group:artifact:version ...
29 # Define the artifacts required from the given maven repository.
33 # It defines several make targets.
36 # Will download the jar files.
39 # Will download and check the signatures using gpg. The public key
40 # required for verification must be imported to gpg separately.
45 # define maven central
46 maven_central_URL:=https://repo1.maven.org/maven2
47 maven_repository_URL:=https://mvnrepository.com/artifact
49 # find out what repositories the makefile defined
50 maven_REPOS=$(patsubst maven_%_URL,%,$(filter maven_%_URL,$(.VARIABLES)))
52 dist_EXTRA+=maven.make
54 # (group artifact version baseurl)
59 wget -O $$@ $(4)/$(subst .,/,$1)/$2/$3/$2-$3.jar || ( rm $$@ ; exit 1 )
62 wget -O $$@ $(4)/$(subst .,/,$1)/$2/$3/$2-$3.pom || ( rm $$@ ; exit 1 )
63 .lib-sources/$2-$3-sources.jar:
65 wget -O $$@ $(4)/$(subst .,/,$1)/$2/$3/$2-$3-sources.jar || ( rm $$@ ; exit 1 )
66 .lib-javadoc/$2-$3-javadoc.jar:
68 wget -O $$@ $(4)/$(subst .,/,$1)/$2/$3/$2-$3-javadoc.jar || ( rm $$@ ; exit 1 )
69 .lib/$2-$3.jar.asc: .lib/$2-$3.jar
70 wget -O $$@ $(4)/$(subst .,/,$1)/$2/$3/$2-$3.jar.asc
71 gpg --batch --verify $$@ $$< || ( rm $$@ ; echo "GPG verification failed, you may need to import the public key." ; exit 1 )
72 maven-init: .lib/$2-$3.jar .lib-sources/$2-$3-sources.jar .lib-javadoc/$2-$3-javadoc.jar .lib/$2-$3.pom
73 maven-verify: .lib/$2-$3.jar.asc
79 .PHONY: maven-init maven-verify
81 $(foreach repo,$(maven_REPOS),\
82 $(foreach jar,$(maven_$(repo)_JARS), \
83 $(eval $(call maven_func,$(word 1,$(subst :, ,$(jar))),$(word 2,$(subst :, ,$(jar))),$(word 3,$(subst :, ,$(jar))),$(maven_$(repo)_URL)))))
86 rm -rf .lib .lib-javadoc .lib-sources