我试图以编程方式解决pom,但遇到了几个错误。
下面是代码片段:
ContainerConfiguration config = new DefaultContainerConfiguration();
config.setAutoWiring(true);
config.setClassPathScanning(PlexusConstants.SCANNING_INDEX);
PlexusContainer plexusContainer = new DefaultPlexusContainer(config);
ProjectBuilder projectBuilder = plexusContainer.lookup(ProjectBuilder.class);
RepositorySystem repositorySystem = plexusContainer.lookup(RepositorySystem.class);
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
LocalRepository localRepository = new LocalRepository("target/.m2");
session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(session, localRepository));
DefaultProjectBuildingRequest request = new DefaultProjectBuildingRequest();
request.setRepositorySession(session);
request.setResolveDependencies(true);
ArtifactRepository centralRepository = new MavenArtifactRepository();
centralRepository.setUrl("https://repo.maven.apache.org/maven2/");
centralRepository.setLayout(new DefaultRepositoryLayout());
request.setRemoteRepositories(Collections.singletonList(centralRepository));
ProjectBuildingResult result = projectBuilder.build(new File("pom.xml"), request);
result.getDependencyResolutionResult().getDependencies().forEach(dependency ->
System.out.println(
"Provided pom depends on: " +
dependency.getArtifact().getGroupId() +
":" + dependency.getArtifact().getGroupId() +
":" + dependency.getArtifact().getVersion()
)
);
但不幸的是,我在执行projectBuilder时最终出现了这样的错误。构建(新文件(“pom.xml”),请求)
Caused by: org.apache.maven.model.building.ModelBuildingException:
15 problems were encountered while building the effective model for net.dahanne:maven-resolver:0.0.1-SNAPSHOT
[ERROR] Invalid artifact repository: null @
[ERROR] Failed to determine Java version for profile jdk8 @ io.dropwizard.metrics:metrics-parent:4.1.17, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/io/dropwizard/metrics/metrics-parent/4.1.17/metrics-parent-4.1.17.pom, line 160, column 22
[ERROR] Failed to determine Java version for profile doclint-java8-disable @ org.jboss:jboss-parent:36, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jboss-parent/36/jboss-parent-36.pom, line 839, column 17
[ERROR] Failed to determine Java version for profile compile-java8-release-flag @ org.jboss:jboss-parent:36, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jboss-parent/36/jboss-parent-36.pom, line 879, column 18
[ERROR] Failed to determine Java version for profile include-jdk-misc @ org.jboss:jboss-parent:36, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jboss-parent/36/jboss-parent-36.pom, line 910, column 22
[ERROR] Failed to determine Java version for profile java8-test @ org.jboss:jboss-parent:36, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jboss-parent/36/jboss-parent-36.pom, line 961, column 22
[ERROR] Failed to determine Java version for profile java9-mr-build @ org.jboss:jboss-parent:36, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jboss-parent/36/jboss-parent-36.pom, line 998, column 22
[ERROR] Failed to determine Java version for profile java9-test @ org.jboss:jboss-parent:36, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jboss-parent/36/jboss-parent-36.pom, line 1047, column 22
[ERROR] Failed to determine Java version for profile java10-mr-build @ org.jboss:jboss-parent:36, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jboss-parent/36/jboss-parent-36.pom, line 1087, column 22
[ERROR] Failed to determine Java version for profile java10-test @ org.jboss:jboss-parent:36, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jboss-parent/36/jboss-parent-36.pom, line 1139, column 22
[ERROR] Failed to determine Java version for profile java11-mr-build @ org.jboss:jboss-parent:36, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jboss-parent/36/jboss-parent-36.pom, line 1182, column 22
[ERROR] Failed to determine Java version for profile java11-test @ org.jboss:jboss-parent:36, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jboss-parent/36/jboss-parent-36.pom, line 1237, column 22
[ERROR] Failed to determine Java version for profile java12-mr-build @ org.jboss:jboss-parent:36, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jboss-parent/36/jboss-parent-36.pom, line 1283, column 22
[ERROR] Failed to determine Java version for profile java12-test @ org.jboss:jboss-parent:36, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jboss-parent/36/jboss-parent-36.pom, line 1341, column 22
[ERROR] Failed to determine Java version for profile java13-mr-build @ org.jboss:jboss-parent:36, /Users/anthony.dahanne/workspaces/maven-resolver/target/.m2/org/jboss/jboss-parent/36/jboss-parent-36.pom, line 1390, column 22
看起来maven解析器无法设置正在遍历的POM的属性。。。
我有一个完整的github项目来演示这个问题,包括CI。
我还交叉发布了Maven-dev邮件列表。
谢谢
HervéBoutemy通过github repo上的PR发送了修复,我在那里演示了该问题-我确实错过了一些配置。
当您组装请求时,您需要将Java版本作为系统属性传递。对我有用的是类似的东西:
final Properties systemProperties = new Properties();
systemProperties.setProperty("java.version", "1.8");
final DefaultProjectBuildingRequest projectBuildingRequest = new DefaultProjectBuildingRequest();
projectBuildingRequest.setSystemProperties(systemProperties);
问题来自JdkVersionProfileActivator类,它显式地检查java的值。系统属性中的版本属性。
编辑:我刚刚检查了链接的Github问题,其他人已经发送了一份带有类似解决方案的PR,并进行了一些额外的改进,如使用<代码>系统。getProperties()获取属性,而不是手动为其创建对象。
我正在使用jenkins构建WSO2项目,在构建过程中遇到了一些问题。有人能帮忙解决这个问题吗?例外情况: 错误:无法分析POMs组织。阿帕奇。专家项目ProjectBuildingException:处理POMs:[错误]'模块时遇到一些问题。模块[2]”指定重复的子模块VBReadFromEmailBody ESB@org第14行第13列。阿帕奇。专家项目DefaultProjectBuild
运行Maven测试时出现此错误 执行目标组织失败。阿帕奇。专家插件:maven插件插件:3.2:项目amsframeworok上的描述符(默认描述符):提取插件描述符时出错:“未找到插件:ams5的mojo定义。0:amsframeworok。'- 下面是我的pom。xml
我创建并尝试使用构建项目,但它不工作。不是这个项目,我试着构建我的所有项目,但在我的ubuntu笔记本电脑上不工作 [信息]扫描项目...从中心下载:https://repo . maven . Apache . org/maven 2/org/spring framework/boot/spring-boot-starter-parent/2 . 6 . 11/spring-boot-start
我正在尝试从何处运行此源代码https://github.com/kishancs2020/TicketBookingServiceJunitTestingGithub在我的Jenkins中查看了在Jenkins文件中创建的管道源代码。 我已经更新了maven,java版本来修复它,但错误仍然是一样的。我也通过了这个链接http://cwiki.apache.org/confluence/disp
来自Eclipse火星版,pom。xml-Run-As-maven-clean,我得到了以下关于构建失败的错误消息 [ERROR]无法执行目标组织。阿帕奇。专家插件:maven clean插件:2.5:项目测试框架上的clean(默认清洁):目标组织的执行默认清洁。阿帕奇。专家插件:maven clean插件:2.5:clean失败:插件组织。阿帕奇。专家plugins:maven clean p
我目前正在制作一个Spigot插件,为了构建这个插件,我使用了生命周期包构建。我正在制作的Spigot插件实际上是一个API,所以很自然地我想包含JavaDocs。问题是,我已经制作了JavaDocs,我知道只是觉得我需要将maven-javadoc-plugin放在我的构建和报告中。但是,每当我重新加载maven更改时,我在构建时都会收到错误,说*Plugin。这很不幸,因为我已经在这个插件上查