Skip to content

Commit f6db9fb

Browse files
committed
[MCOMPILER-525] - Incremental recompile incorrect detection of dependency change
Signed-off-by: Jorge Solórzano <[email protected]>
1 parent 3f95d39 commit f6db9fb

File tree

7 files changed

+293
-80
lines changed

7 files changed

+293
-80
lines changed

src/it/MCOMPILER-275_separate-moduleinfo/verify.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def log = new File( basedir, 'build.log').text
2020

2121
assert log.count( "[INFO] Toolchain in maven-compiler-plugin: JDK" ) == 1
2222

23-
assert log.count( "[INFO] Changes detected - recompiling the module!" ) == 3
23+
assert log.count( "[INFO] Changes detected - recompiling the module" ) == 3
2424

2525
// major_version: 52 = java8 -> execution id "base-compile"
2626
assert new File( basedir, 'target/classes/com/foo/MyClass.class' ).bytes[7] == 52

src/it/MCOMPILER-500-package-info-incr/verify.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def logFile = new File( basedir, 'build.log' )
2121
assert logFile.exists()
2222
content = logFile.text
2323

24-
assert 1 == content.count( 'Changes detected - recompiling the module!' )
24+
assert 1 == content.count( 'Changes detected - recompiling the module' )
2525
assert 1 == content.count( 'Nothing to compile - all classes are up to date' )
2626

2727

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.
17+
18+
# NOTE: The first time, we run up to "integration-test" phase which includes the AntRun execution which saves the
19+
# timestamp of the first JAR for comparison with the timestamp of the JAR from the final "package" invocation.
20+
# Note:
21+
invoker.goals = clean integration-test package -Dmaven.compiler.showCompilationChanges=true

src/it/MCOMPILER-525/pom.xml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<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/maven-v4_0_0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
<groupId>org.apache.maven.plugins</groupId>
23+
<artifactId>MCOMPILER-525-no-recreation</artifactId>
24+
<name>MCOMPILER-525-no-recreation</name>
25+
<packaging>jar</packaging>
26+
<version>1.0-SNAPSHOT</version>
27+
28+
<build>
29+
<plugins>
30+
<plugin>
31+
<groupId>org.apache.maven.plugins</groupId>
32+
<artifactId>maven-compiler-plugin</artifactId>
33+
<version>@project.version@</version>
34+
</plugin>
35+
<plugin>
36+
<groupId>org.apache.maven.plugins</groupId>
37+
<artifactId>maven-jar-plugin</artifactId>
38+
<version>3.3.0</version>
39+
</plugin>
40+
<plugin>
41+
<groupId>org.apache.maven.plugins</groupId>
42+
<artifactId>maven-antrun-plugin</artifactId>
43+
<version>3.1.0</version>
44+
<executions>
45+
<execution>
46+
<id>touch</id>
47+
<phase>integration-test</phase>
48+
<goals>
49+
<goal>run</goal>
50+
</goals>
51+
<configuration>
52+
<target>
53+
<!-- Save the JAR and especially its timestamp for evaluation by the post-build hook script -->
54+
<copy file="target/MCOMPILER-525-no-recreation-1.0-SNAPSHOT.jar"
55+
tofile="target/reference.jar"
56+
preservelastmodified="true" overwrite="true"/>
57+
</target>
58+
</configuration>
59+
</execution>
60+
</executions>
61+
</plugin>
62+
</plugins>
63+
</build>
64+
</project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package myproject;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
/**
23+
* The classic Hello World App.
24+
*/
25+
public class HelloWorld {
26+
27+
/**
28+
* Main method.
29+
*
30+
* @param args Not used
31+
*/
32+
public static void main( String[] args )
33+
{
34+
System.out.println( "Hi!" );
35+
}
36+
}

src/it/MCOMPILER-525/verify.groovy

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
/*
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
import java.nio.file.*;
22+
import java.time.*;
23+
import java.time.temporal.*
24+
import java.util.*;
25+
26+
File target = new File( basedir, "target" );
27+
assert target.isDirectory()
28+
29+
File jarFile = new File( target, "MCOMPILER-525-no-recreation-1.0-SNAPSHOT.jar" );
30+
assert jarFile.isFile()
31+
32+
File refFile = new File( target, "reference.jar" );
33+
assert refFile.isFile()
34+
35+
Instant referenceTimestamp = Files.getLastModifiedTime( refFile.toPath() )
36+
.toInstant().truncatedTo( ChronoUnit.MILLIS );
37+
System.out.println( "Reference timestamp: " + referenceTimestamp );
38+
39+
Instant actualTimestamp = Files.getLastModifiedTime( jarFile.toPath() )
40+
.toInstant().truncatedTo( ChronoUnit.MILLIS );
41+
System.out.println( "Actual timestamp : " + actualTimestamp );
42+
43+
assert referenceTimestamp.equals(actualTimestamp),
44+
"Timestamps don't match, JAR was recreated although contents has not changed"

0 commit comments

Comments
 (0)