I have two projects:
- An Eclipse project build with pomless Tycho approach
- A plain Java project build with plain Maven, no OSGI, no Tycho
I need to use some of the bundles from the 1st project in the 2nd project. I tried to install the jar files from the 1st project into a local maven repository using mvn clean install
. And tried to reference them from the 2nd project. But I get the following error:
Failed to execute goal on project ...: Could not resolve dependencies for project ...: Failed to collect dependencies at bpms:bpms.util.jdk:jar:0.1.0-SNAPSHOT: Failed to read artifact descriptor for bpms:bpms.util.jdk:jar:0.1.0-SNAPSHOT: Failure to find bpms:bundles:pom:1.0.0-SNAPSHOT in https://repo.maven.apache.org/maven2 was cached in the local repository, the resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
The bpms.util.jdk-0.1.0-SNAPSHOT.pom
file contains the following:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>bpms</groupId>
<artifactId>bundles</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>..\.polyglot.pom.tycho</relativePath>
</parent>
<artifactId>bpms.util.jdk</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>jdk utils</name>
</project>
It seems that the problem is caused by the parent artifact. Is it possible to install my artifacts as standalone artifacts without reference to parent bundles
?
What is the right approach? I can't use a pomless Tycho and should define a separate pom.xml for each bundle?
CodePudding user response:
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="