Skip to content

Commit e95fc97

Browse files
Apply suggestions from code review
Co-authored-by: Erik Meuwese <Erik.Meuwese@topicus.nl>
1 parent 8c74428 commit e95fc97

File tree

6 files changed

+106
-83
lines changed

6 files changed

+106
-83
lines changed

src/main/java/org/apache/maven/buildcache/xml/DtoUtils.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import javax.annotation.Nonnull;
2222

2323
import java.io.File;
24+
import java.nio.file.FileSystems;
2425
import java.nio.file.Path;
2526
import java.util.List;
2627

@@ -113,6 +114,15 @@ public static Dependency createDependency(Artifact artifact) {
113114
return dependency;
114115
}
115116

117+
/**
118+
* @deprecated use {@link #addProperty(CompletedExecution, String, Object, Path, boolean)}
119+
*/
120+
@Deprecated
121+
public static void addProperty(
122+
CompletedExecution execution, String propertyName, Object value, String baseDirPath, boolean tracked) {
123+
addProperty(execution, propertyName, value, FileSystems.getDefault().getPath(baseDirPath), tracked);
124+
}
125+
116126
public static void addProperty(
117127
CompletedExecution execution, String propertyName, Object value, Path baseDirPath, boolean tracked) {
118128
final PropertyValue valueType = new PropertyValue();
@@ -203,7 +213,8 @@ private static String normalizedPath(Path path, Path baseDirPath) {
203213
boolean isProjectSubdir = path.isAbsolute() && path.startsWith(baseDirPath);
204214
if (LOGGER.isDebugEnabled()) {
205215
LOGGER.debug(
206-
"normalizedPath isProjectSubdir {} path '{}' - baseDirPath '{}', path.isAbsolute() {}, path.startsWith(baseDirPath) {}",
216+
"normalizedPath isProjectSubdir {} path '{}' - baseDirPath '{}', path.isAbsolute() {},"
217+
+ " path.startsWith(baseDirPath) {}",
207218
isProjectSubdir,
208219
path,
209220
baseDirPath,

src/test/projects/reconcile-expressions/.mvn/extensions.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
1818
-->
1919
<extensions>
20-
<extension>
21-
<groupId>org.apache.maven.extensions</groupId>
22-
<artifactId>maven-build-cache-extension</artifactId>
23-
<version>${projectVersion}</version>
24-
</extension>
20+
<extension>
21+
<groupId>org.apache.maven.extensions</groupId>
22+
<artifactId>maven-build-cache-extension</artifactId>
23+
<version>${projectVersion}</version>
24+
</extension>
2525
</extensions>

src/test/projects/reconcile-expressions/.mvn/maven-build-cache-config.xml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,32 @@ under the License.
2222
<cache xmlns="http://maven.apache.org/BUILD-CACHE-CONFIG/1.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2323
xsi:schemaLocation="http://maven.apache.org/BUILD-CACHE-CONFIG/1.3.0 https://maven.apache.org/xsd/build-cache-config-1.3.0.xsd">
2424

25-
<executionControl>
26-
<reconcile>
27-
<plugins>
28-
<!-- Test expression reconciliation for resources plugin -->
29-
<plugin goal="resources" artifactId="maven-resources-plugin" groupId="org.apache.maven.plugins">
30-
<reconciles>
31-
<!-- Test with project.version expression -->
32-
<reconcile propertyName="project.version" expression="${project.version}"/>
33-
<!-- Test with custom property expression -->
34-
<reconcile propertyName="product.name" expression="${product.name}"/>
35-
<!-- Test with build environment property -->
36-
<reconcile propertyName="build.environment" expression="${build.environment}"/>
37-
</reconciles>
38-
</plugin>
39-
<!-- Test expression reconciliation for compiler plugin -->
40-
<plugin goal="compile" artifactId="maven-compiler-plugin" groupId="org.apache.maven.plugins">
41-
<reconciles>
42-
<!-- Test with project groupId expression -->
43-
<reconcile propertyName="project.groupId" expression="${project.groupId}"/>
44-
<!-- Test with project artifactId expression -->
45-
<reconcile propertyName="project.artifactId" expression="${project.artifactId}"/>
46-
<!-- Test with combined expression using multiple properties -->
47-
<reconcile propertyName="custom.timestamp" expression="${custom.timestamp}"/>
48-
</reconciles>
49-
</plugin>
50-
</plugins>
51-
</reconcile>
52-
</executionControl>
53-
</cache>
25+
<executionControl>
26+
<reconcile>
27+
<plugins>
28+
<!-- Test expression reconciliation for resources plugin -->
29+
<plugin goal="resources" artifactId="maven-resources-plugin" groupId="org.apache.maven.plugins">
30+
<reconciles>
31+
<!-- Test with project.version expression -->
32+
<reconcile propertyName="project.version" expression="${project.version}"/>
33+
<!-- Test with custom property expression -->
34+
<reconcile propertyName="product.name" expression="${product.name}"/>
35+
<!-- Test with build environment property -->
36+
<reconcile propertyName="build.environment" expression="${build.environment}"/>
37+
</reconciles>
38+
</plugin>
39+
<!-- Test expression reconciliation for compiler plugin -->
40+
<plugin goal="compile" artifactId="maven-compiler-plugin" groupId="org.apache.maven.plugins">
41+
<reconciles>
42+
<!-- Test with project groupId expression -->
43+
<reconcile propertyName="project.groupId" expression="${project.groupId}"/>
44+
<!-- Test with project artifactId expression -->
45+
<reconcile propertyName="project.artifactId" expression="${project.artifactId}"/>
46+
<!-- Test with combined expression using multiple properties -->
47+
<reconcile propertyName="custom.timestamp" expression="${custom.timestamp}"/>
48+
</reconciles>
49+
</plugin>
50+
</plugins>
51+
</reconcile>
52+
</executionControl>
53+
</cache>

src/test/projects/reconcile-expressions/pom.xml

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,50 @@ under the License.
1919
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
2020
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2121

22-
<modelVersion>4.0.0</modelVersion>
23-
<groupId>org.apache.maven.caching.test.reconcile</groupId>
24-
<artifactId>reconcile-expressions</artifactId>
25-
<version>1.0.0-SNAPSHOT</version>
26-
<packaging>jar</packaging>
22+
<modelVersion>4.0.0</modelVersion>
23+
<groupId>org.apache.maven.caching.test.reconcile</groupId>
24+
<artifactId>reconcile-expressions</artifactId>
25+
<version>1.0.0-SNAPSHOT</version>
26+
<packaging>jar</packaging>
2727

28-
<properties>
29-
<maven.compiler.source>1.8</maven.compiler.source>
30-
<maven.compiler.target>1.8</maven.compiler.target>
31-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
32-
<!-- Custom properties to test expression reconciliation -->
33-
<product.name>TestProduct</product.name>
34-
<build.environment>development</build.environment>
35-
<custom.timestamp>2024-01-01</custom.timestamp>
36-
</properties>
28+
<properties>
29+
<maven.compiler.source>1.8</maven.compiler.source>
30+
<maven.compiler.target>1.8</maven.compiler.target>
31+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
32+
<!-- Custom properties to test expression reconciliation -->
33+
<product.name>TestProduct</product.name>
34+
<build.environment>development</build.environment>
35+
<custom.timestamp>2024-01-01</custom.timestamp>
36+
</properties>
37+
<build>
38+
<resources>
39+
<resource>
40+
<directory>src/main/resources</directory>
41+
<filtering>true</filtering>
42+
</resource>
43+
</resources>
3744

45+
<pluginManagement>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.codehaus.mojo</groupId>
49+
<artifactId>versions-maven-plugin</artifactId>
50+
<version>2.18.0</version>
51+
</plugin>
52+
<plugin>
53+
<groupId>org.apache.maven.plugins</groupId>
54+
<artifactId>maven-resources-plugin</artifactId>
55+
<version>3.3.1</version>
56+
</plugin>
57+
<plugin>
58+
<groupId>org.apache.maven.plugins</groupId>
59+
<artifactId>maven-compiler-plugin</artifactId>
60+
<version>3.11.0</version>
61+
</plugin>
62+
</plugins>
63+
</pluginManagement>
64+
</build>
3865

39-
40-
<build>
41-
<resources>
42-
<resource>
43-
<directory>src/main/resources</directory>
44-
<filtering>true</filtering>
45-
</resource>
46-
</resources>
47-
48-
<pluginManagement>
49-
<plugins>
50-
<plugin>
51-
<groupId>org.codehaus.mojo</groupId>
52-
<artifactId>versions-maven-plugin</artifactId>
53-
<version>2.18.0</version>
54-
</plugin>
55-
<plugin>
56-
<groupId>org.apache.maven.plugins</groupId>
57-
<artifactId>maven-resources-plugin</artifactId>
58-
<version>3.3.1</version>
59-
</plugin>
60-
<plugin>
61-
<groupId>org.apache.maven.plugins</groupId>
62-
<artifactId>maven-compiler-plugin</artifactId>
63-
<version>3.11.0</version>
64-
</plugin>
65-
</plugins>
66-
</pluginManagement>
67-
</build>
68-
69-
<dependencies>
70-
</dependencies>
71-
66+
<dependencies>
67+
</dependencies>
7268
</project>

src/test/projects/reconcile-expressions/src/main/java/org/apache/maven/buildcache/Test1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ public class Test1 {
2626
public String getMessage() {
2727
return "Hello from Test1";
2828
}
29-
}
29+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
117
productName=@product.name@
218
version=@project.version@
319
env=@build.environment@

0 commit comments

Comments
 (0)