gpt4 book ai didi

java - POM 依赖项中的变量。 maven 如何知道 SWT 的 Artifact ID?

转载 作者:行者123 更新时间:2023-11-30 09:10:20 25 4
gpt4 key购买 nike

描述了piccolo2d-swt 的依赖项here作为

Group: ${swt.groupId}
Artifact: ${swt.artifactId}
Version: [3.3.0-v3346,)

如何解决?它在哪里获取变量的值?

如果我使用此依赖项运行空项目,它会显示一些错误消息,其中提到 org.eclipse.swt.win32

它从哪里获取这个值?

如果我打印出这些变量的值,我什么也得不到。

POM 在这里

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Test_DisplayMavenVariables</groupId>
<artifactId>Test_DisplayMavenVariables</artifactId>
<version>0.0.1-SNAPSHOT</version>


<properties>
<testproperty>This is a test property</testproperty>
</properties>


<!--
<dependencies>

<dependency>
<groupId>org.piccolo2d</groupId>
<artifactId>piccolo2d-swt</artifactId>
<version>1.3.1</version>
</dependency>


</dependencies>
-->

<build>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Displaying value of some properties</echo>
<echo>[testproperty] ${testproperty}</echo>
<echo>[swt.artifactId] ${swt.artifactId}</echo>
<echo>[swt.groupId] ${swt.groupId}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>


<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>[1.1,)</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>

最佳答案

swt.groupIdswt.artifactId 变量是通过 piccolo2d-swt pom file 中的 maven 配置文件定义的,例如:

<profile>
<id>windows_x86</id>
<activation>
<os>
<family>windows</family>
<arch>x86</arch>
</os>
</activation>
<properties>
<swt.groupId>org.eclipse.swt.win32.win32</swt.groupId>
<swt.artifactId>x86</swt.artifactId>
</properties>
</profile>

正在为每个平台定义配置文件,并根据运行 maven 时检测到的 os.familyos.arch 激活配置文件。

关于java - POM 依赖项中的变量。 maven 如何知道 SWT 的 Artifact ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22592050/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com