Maven项目属性是否具有一次写入语义

Maven项目属性是否具有一次写入语义,maven,Maven,今天我观察到一个让我困惑的专业行为。要么项目属性具有某种一次写入语义,要么。。。我没有找到任何可以解释这种行为的参考文档 我可以在验证阶段动态设置Maven属性,以便在以后的阶段将它们作为插件属性进行评估吗 目标 基于其他属性的存在,我想跳过概要文件中插件的执行 计划 在validate阶段运行Groovy插件 评估其他财产的存在 设置“跳过项目”属性 使用skip属性配置在以后阶段运行的插件 POM摘录 <profile> <id>my-id</id>

今天我观察到一个让我困惑的专业行为。要么项目属性具有某种一次写入语义,要么。。。我没有找到任何可以解释这种行为的参考文档

我可以在验证阶段动态设置Maven属性,以便在以后的阶段将它们作为插件属性进行评估吗

目标

基于其他属性的存在,我想跳过概要文件中插件的执行

计划

  • validate
    阶段运行Groovy插件
  • 评估其他财产的存在
  • 设置“跳过项目”属性
  • 使用skip属性配置在以后阶段运行的插件
  • POM摘录

    <profile>
        <id>my-id</id>
        <activation>
            <file>
                <exists>${basedir}/somefile</exists>
            </file>
        </activation>
        <properties>
            <skipIt>false</skipIt> <!-- intention: use this as default value -->
        </properties>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.gmavenplus</groupId>
                    <artifactId>gmavenplus-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>validate</phase>
                            <goals>
                                <goal>execute</goal>
                            </goals>
                            <configuration>
                                <scripts>
                                    <script>
                                    <![CDATA[
                                    def someOtherProp = project.properties['some-other-property']
                                    def skipIt = someOtherProp ? 'false' : 'true'
                                    project.properties['skipIt'] = skipIt
                                    println skipIt
                                    println project.properties['skipIt']
                                    ]]>
                                    </script>
                                </scripts>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <configuration>
                        <skip>${skipIt}</skip>
                    </configuration>
                    <executions>
                        <execution>
                            <id>my-unpack</id>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
    
    
    我的身份证
    ${basedir}/somefile
    假的
    org.codehaus.gmavenplus
    gmavenplus插件
    验证
    执行
    maven依赖插件
    ${skipIt}
    我的行李
    过程资源
    打开
    
    行为

    如果
    某些其他属性
    不存在(即未设置),则打印两次
    true
    。这意味着Groovy计算是正确的,并且正确设置了
    skipIt
    。然而,依赖插件仍然运行
    myunpack
    执行。为什么?


    但是,如果我删除第9行的
    false
    ,一切都会按照我的预期工作。为什么?

    这回答了你的问题吗?这与我的问题AFAICS无关(除了Maven、配置文件和涉及的属性)。gmavenplus插件是否真的改变了项目属性,还是仅仅改变了它的一些副本?@JFabianMeier好主意!但是,如果它在副本上运行,那么如果我删除
    false
    ,行为不会改变,是吗?