我有两个项目:
项目构建了纯文本,没有OSGI,没有Tycho
我需要使用一些捆绑从第一个项目在第二个项目。我尝试使用mvn clean install
将第一个项目中的jar文件安装到本地maven存储库中。并试图从第二个项目中参考他们。但我得到了以下错误:
未能为项目执行目标.:未能在bpms中收集依赖项:bpms:bpms.util.jdk:jar:0.1.0-快照:未能读取bpms的工件描述符:bpms.util.jdk:jar:0.1.0-快照:未能找到bpms:bundle:pom:1.0.0-在本地存储库中缓存了https://repo.maven.apache.org/maven2中的快照,在中央更新间隔过去之前不会重新尝试该解决方案,或者强制更新->帮助1。
bpms.util.jdk-0.1.0-SNAPSHOT.pom
文件包含以下内容:
<?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>
这个问题似乎是由父工件引起的。是否可以在不引用父bundles
的情况下将我的工件安装为独立的工件?
什么是正确的方法?我不能使用无浮点的Tycho,应该为每个包定义一个单独的pom.xml?
发布于 2021-11-30 02:11:51
似乎最简单的方法是使用mvn install:install-file
安装jar文件。下面是一个对某人有用的bat文件:
@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"
)
)
)
)
它以下列格式从groupId
文件中读取deps.txt
和artifactId
:
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
起初,它试图在BUNDLES_HOME
中找到一个包。如果找到,它将从META-INF/MANIFEST.MF
读取一个包版本,并将jar安装到本地maven存储库中。pom-文件生成。
如果在BUNDLES_HOME
中找不到包,那么它就会尝试在ECLIPSE_HOME
中找到它。
第二个脚本读取deps.txt
并为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
)
)
)
)
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
和pom-文件依赖生成器:
#!/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
https://stackoverflow.com/questions/70156835
复制相似问题