POM依赖项中的变量。 maven如何知道SWT的工件ID?

时间:2014-03-23 14:16:56

标签: java eclipse maven

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>

1 个答案:

答案 0 :(得分:2)

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激活配置文件。