Skip to content

The change in the mvn -P parameter does not invalidate the cache #414

@wangkang5

Description

@wangkang5

Affected version

1.2.1

Bug description

After executing the command mvn clean package -Dmaven.test.skip=true -Pdev -f ./pom.xml, and then modifying the -P parameter to execute mvn clean package -Dmaven.test.skip=true -Ptest -f ./pom.xml, the build retrieved an incorrect cache.
pom.xml

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <fork>true</fork>
                    <mainClass>ServerApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>spring-service-dubbo.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources/${profiles.active}</directory>
            </resource>
        </resources>
    </build>

I tried to modify the maven-build-cache-config.xml by adding the following configuration:

<reconcile logAllProperties="true">
    <plugins>
        <plugin artifactId="maven-resources-plugin" goal="resources">
          <reconciles>
            <reconcile propertyName="resources"/>
            <reconcile propertyName="filtering"/>
          </reconciles>
        </plugin>
    </plugins>
</reconcile>

Rebuilding the cache is not working anymore.

[INFO] Scanning plugins configurations to find input files. Probing is enabled, values will be checked for presence in file system
[INFO] Found 135 input files. Project dir processing: 12, plugins: 1 millis
...
[INFO] Project inputs calculated in 24 ms. SHA-256 checksum [179be61b922f372ba9a918eb809217a535ff3d9b31c09236bb0a0bee395f38ae] calculated in 163 ms.
[INFO] Attempting to restore project ... from build cache
[INFO] Local build found by checksum 179be61b922f372ba9a918eb809217a535ff3d9b31c09236bb0a0bee395f38ae
[INFO] Found cached build, restoring ... from cache by checksum 179be61b922f372ba9a918eb809217a535ff3d9b31c09236bb0a0bee395f38ae
[WARNING] Tracked property `resources` not found in cached build. Execution: default-resources:resources:process-resources:maven-resources-plugin:org.apache.maven.plugins
[WARNING] Cached build record doesn't contain all tracked properties. Plugin: Plugin [org.apache.maven.plugins:maven-resources-plugin], goal: resources, executionId: default-resources
[INFO] Cached build violates cache rules, cannot restore

Is there a solution to address the issue of differentiating the -P parameter?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions