Maven 如何强制设置指向systemPath的基本目录的属性?

Maven 如何强制设置指向systemPath的基本目录的属性?,maven,maven-enforcer-plugin,Maven,Maven Enforcer Plugin,我试图使用maven enforcer插件强制设置属性。该属性应指向一个目录,并用作某些系统范围依赖项的基本目录。我有以下pom.xml: <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.a

我试图使用maven enforcer插件强制设置属性。该属性应指向一个目录,并用作某些系统范围依赖项的基本目录。我有以下
pom.xml

<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>org.example</groupId>
    <artifactId>maven-enforcer-systempath</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.example</groupId>
            <artifactId>bar</artifactId>
            <version>1.0.0</version>
            <scope>system</scope>
            <systemPath>${non.existent.property}/bar.jar</systemPath>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>1.4.1</version>
                <executions>
                    <execution>
                        <id>enforce-property</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <phase>validate</phase>
                        <configuration>
                            <rules>
                                <requireProperty>
                                    <property>non.existent.property</property>
                                    <message>"non.existent.property" must point to a directory</message>
                                </requireProperty>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
报告的错误出现在调用enforcer插件之前。我认为这是因为美国:

需要范围:test中工件的依赖项集合


如何强制在收集依赖项之前设置属性?

禁止使用系统范围依赖项。。最好将jar放入存储库管理器中,而不是使用它……如果设置变量non.existence.property,${non.existence.property}/bar.jar,您是否测试过${non.existence.property}/bar.jar是否有效?例如?@pirho是的,我测试了这个,它很有效。我只是偶然发现了这一点,因为一位同事在其本地设置中没有设置该属性,因此出现了该错误。我只是想告诉大家,我的Eclipse pom编辑器即使未运行也会出现相同的错误。请防止使用系统范围依赖项。。最好将jar放入存储库管理器中,而不是使用它……如果设置变量non.existence.property,${non.existence.property}/bar.jar,您是否测试过${non.existence.property}/bar.jar是否有效?例如?@pirho是的,我测试了这个,它很有效。我只是偶然发现了这一点,因为一位同事在他的本地设置中没有设置该属性,所以出现了该错误。
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.systemPath' for org.example:bar:jar must specify an absolute path but is ${non.existent.property}/bar.jar @ line 14, column 16
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project org.example:maven-enforcer-systempath:0.0.1-SNAPSHOT (C:\Users\workingcopy\maven-enforcer-systempath\pom.xml) has 1 error
[ERROR]     'dependencies.dependency.systemPath' for org.example:bar:jar must specify an absolute path but is ${non.existent.property}/bar.jar @ line 14, column 16
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException