It seems that the simplest approach is to install jar files using mvn install:install-file
. Here is a bat-file that could be useful for someone:
@echo off
set MVN_HOME=C:/Tools/apache-maven-3.6.3
set BUNDLES_HOME=C:/Work/workspace-bpms-trunk/bundles
set ECLIPSE_HOME=C:/Tools/eclipse/plugins
set PATH=%MVN_HOME%/bin;%PATH%
for /f "tokens=1,2 delims=:" %%E in (deps.txt) do (
if exist %BUNDLES_HOME%/%%F (
for /f "tokens=1,2 delims=: " %%G in (%BUNDLES_HOME%/%%F/META-INF/MANIFEST.MF) do (
if "%%G" == "Bundle-Version" (
call mvn install:install-file -DgroupId=%%E -DartifactId=%%F -Dversion=%%~nH-SNAPSHOT -DgeneratePom=true -Dpackaging=jar -Dfile="%BUNDLES_HOME%/%%F/target/%%F-%%~nH-SNAPSHOT.jar"
)
)
) else (
for %%G in (%ECLIPSE_HOME%/%%F_*.jar) do (
for /f "tokens=2 delims=_" %%H in ("%%~nG") do (
call mvn install:install-file -DgroupId=%%E -DartifactId=%%F -Dversion=%%H -DgeneratePom=true -Dpackaging=jar -Dfile="%ECLIPSE_HOME%/%%~nG.jar"
)
)
)
)
It reads groupId
and artifactId
from deps.txt
file of the following format:
org.eclipse.ocl:org.eclipse.ocl
org.eclipse.ocl:org.eclipse.ocl.common
org.eclipse.ocl:org.eclipse.ocl.ecore
org.eclipse.ocl:org.eclipse.ocl.pivot
At first it tries to find a bundle in BUNDLES_HOME
. If found then it reads a bundle version from META-INF/MANIFEST.MF
and installs jar into a local maven repository. pom-files are generated.
If the bundle not found in BUNDLES_HOME
then it tries to find it in ECLIPSE_HOME
.
The second script reads deps.txt
and generates a list of dependencies for pom.xml
:
@echo off
set BUNDLES_HOME=C:/Work/workspace-bpms-trunk/bundles
set ECLIPSE_HOME=C:/Tools/eclipse/plugins
break > deps-gen.txt
for /f "tokens=1,2 delims=:" %%E in (deps.txt) do (
if exist %BUNDLES_HOME%/%%F (
for /f "tokens=1,2 delims=: " %%G in (%BUNDLES_HOME%/%%F/META-INF/MANIFEST.MF) do (
if "%%G" == "Bundle-Version" (
echo ^<dependency^>>> deps-gen.txt
echo ^<groupId^>%%E^</groupId^>>> deps-gen.txt
echo ^<artifactId^>%%F^</artifactId^>>> deps-gen.txt
echo ^<version^>%%~nH-SNAPSHOT^</version^>>> deps-gen.txt
echo ^</dependency^>>> deps-gen.txt
)
)
) else (
for %%G in (%ECLIPSE_HOME%/%%F_*.jar) do (
for /f "tokens=2 delims=_" %%H in ("%%~nG") do (
echo ^<dependency^>>> deps-gen.txt
echo ^<groupId^>%%E^</groupId^>>> deps-gen.txt
echo ^<artifactId^>%%F^</artifactId^>>> deps-gen.txt
echo ^<version^>%%H^</version^>>> deps-gen.txt
echo ^</dependency^>>> deps-gen.txt
)
)
)
)
A similar installer for Linux:
#!/bin/bash
BUNDLES_HOME=~/workspaces/workspace-bpms-trunk/bundles
ECLIPSE_PLUGINS=~/.p2/pool/plugins
while IFS=":" read -r group artifact || [ -n "$p" ]; do
artifact="${artifact//[$'\r\n']}"
if [ "$artifact" = "" ]; then
:
elif [ -d "$BUNDLES_HOME/$artifact" ]; then
while IFS=":" read -r key value || [ -n "$p" ]; do
if [ "$key" = "Bundle-Version" ]; then
version="${value//[[:space:]]/}"
version="${version/.qualifier/-SNAPSHOT}"
mvn install:install-file -DgroupId=$group -DartifactId=$artifact \
-Dversion=$version -DgeneratePom=true -Dpackaging=jar \
-Dfile="$BUNDLES_HOME/$artifact/target/$artifact-$version.jar"
fi
done < "$BUNDLES_HOME/$artifact/META-INF/MANIFEST.MF"
else
for file in "$ECLIPSE_PLUGINS"/${artifact}_*.jar; do
version="${file%%.jar}"
version="${version##*_}"
mvn install:install-file -DgroupId=$group -DartifactId=$artifact \
-Dversion=$version -DgeneratePom=true -Dpackaging=jar -Dfile="$file"
done
fi
done < deps.txt
And pom-file dependency generator:
#!/bin/bash
BUNDLES_HOME=~/workspaces/workspace-bpms-trunk/bundles
ECLIPSE_PLUGINS=~/.p2/pool/plugins
: > deps-gen.txt
while IFS=":" read -r group artifact || [ -n "$p" ]; do
artifact="${artifact//[$'\r\n']}"
if [ "$artifact" = "" ]; then
echo >> deps-gen.txt
elif [ -d "$BUNDLES_HOME/$artifact" ]; then
while IFS=":" read -r key value || [ -n "$p" ]; do
if [ "$key" = "Bundle-Version" ]; then
version="${value//[[:space:]]/}"
version="${version/.qualifier/-SNAPSHOT}"
echo " <dependency>" >> deps-gen.txt
echo " <groupId>$group</groupId>" >> deps-gen.txt
echo " <artifactId>$artifact</artifactId>" >> deps-gen.txt
echo " <version>$version</version>" >> deps-gen.txt
echo " </dependency>" >> deps-gen.txt
fi
done < "$BUNDLES_HOME/$artifact/META-INF/MANIFEST.MF"
else
for file in "$ECLIPSE_PLUGINS"/${artifact}_*.jar; do
version="${file%%.jar}"
version="${version##*_}"
echo " <dependency>" >> deps-gen.txt
echo " <groupId>$group</groupId>" >> deps-gen.txt
echo " <artifactId>$artifact</artifactId>" >> deps-gen.txt
echo " <version>$version</version>" >> deps-gen.txt
echo " </dependency>" >> deps-gen.txt
done
fi
done < deps.txt