Skip to content

Commit a522b31

Browse files
authored
[MCOMPILER-500] add some parameter to pattern from stale source calculation (#141)
Signed-off-by: Olivier Lamy <olamy@apache.org>
1 parent cdfeb52 commit a522b31

File tree

8 files changed

+226
-8
lines changed

8 files changed

+226
-8
lines changed
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+
invoker.goals = clean compile
19+
invoker.buildResult = success
20+
invoker.goals.2 = compile
21+
invoker.buildResult.2 = success
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
<project
21+
xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
25+
<modelVersion>4.0.0</modelVersion>
26+
27+
<groupId>org.apache.maven.plugins</groupId>
28+
<artifactId>maven-compiler-plugin-it-package-info-incr</artifactId>
29+
<version>1.0.0-SNAPSHOT</version>
30+
<packaging>jar</packaging>
31+
32+
<properties>
33+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
34+
</properties>
35+
<build>
36+
<plugins>
37+
<plugin>
38+
<groupId>org.apache.maven.plugins</groupId>
39+
<artifactId>maven-compiler-plugin</artifactId>
40+
<version>@pom.version@</version>
41+
<configuration>
42+
<createMissingPackageInfoClass>false</createMissingPackageInfoClass>
43+
<incrementalExcludes>
44+
<incrementalExclude>**/package-info.java</incrementalExclude>
45+
</incrementalExcludes>
46+
</configuration>
47+
</plugin>
48+
</plugins>
49+
</build>
50+
</project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package dummy;
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+
public class Person {
24+
private long id;
25+
private String name;
26+
27+
public long getId() {
28+
return id;
29+
}
30+
31+
public String getName() {
32+
return name;
33+
}
34+
35+
public void setName(String name) {
36+
this.name = name;
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package dummy.foo;
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+
public class Person {
24+
private long id;
25+
private String name;
26+
27+
public long getId() {
28+
return id;
29+
}
30+
31+
public String getName() {
32+
return name;
33+
}
34+
35+
public void setName(String name) {
36+
this.name = name;
37+
}
38+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/**
21+
* This is the package javadoc
22+
*/
23+
package dummy;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
def logFile = new File( basedir, 'build.log' )
21+
assert logFile.exists()
22+
content = logFile.text
23+
24+
assert 1 == content.count( 'Changes detected - recompiling the module!' )
25+
assert 1 == content.count( 'Nothing to compile - all classes are up to date' )
26+
27+

src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ public class CompilerMojo
9494
@Parameter
9595
private Set<String> excludes = new HashSet<>();
9696

97+
/**
98+
* A list of exclusion filters for the incremental calculation.
99+
* @since 3.11
100+
*/
101+
@Parameter
102+
private Set<String> incrementalExcludes = new HashSet<>();
103+
97104
/**
98105
* <p>
99106
* Specify where to place generated source files created by annotation processing. Only applies to JDK 1.6+
@@ -387,7 +394,7 @@ private List<File> getCompileClasspathElements( MavenProject project )
387394

388395
protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis )
389396
{
390-
if ( includes.isEmpty() && excludes.isEmpty() )
397+
if ( includes.isEmpty() && excludes.isEmpty() && incrementalExcludes.isEmpty() )
391398
{
392399
return new StaleSourceScanner( staleMillis );
393400
}
@@ -397,7 +404,9 @@ protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis )
397404
includes.add( "**/*.java" );
398405
}
399406

400-
return new StaleSourceScanner( staleMillis, includes, excludes );
407+
Set<String> excludesIncr = new HashSet<>( excludes );
408+
excludesIncr.addAll( this.incrementalExcludes );
409+
return new StaleSourceScanner( staleMillis, includes, excludesIncr );
401410
}
402411

403412
protected SourceInclusionScanner getSourceInclusionScanner( String inputFileEnding )
@@ -409,8 +418,9 @@ protected SourceInclusionScanner getSourceInclusionScanner( String inputFileEndi
409418
{
410419
includes.add( defaultIncludePattern );
411420
}
412-
413-
return new SimpleSourceInclusionScanner( includes, excludes );
421+
Set<String> excludesIncr = new HashSet<>( excludes );
422+
excludesIncr.addAll( excludesIncr );
423+
return new SimpleSourceInclusionScanner( includes, excludesIncr );
414424
}
415425

416426
protected String getSource()

src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ public class TestCompilerMojo
9090
@Parameter
9191
private Set<String> testExcludes = new HashSet<>();
9292

93+
/**
94+
* A list of exclusion filters for the incremental calculation.
95+
* @since 3.11
96+
*/
97+
@Parameter
98+
private Set<String> testIncrementalExcludes = new HashSet<>();
99+
93100
/**
94101
* The -source argument for the test Java compiler.
95102
*
@@ -414,7 +421,7 @@ protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis )
414421
{
415422
SourceInclusionScanner scanner;
416423

417-
if ( testIncludes.isEmpty() && testExcludes.isEmpty() )
424+
if ( testIncludes.isEmpty() && testExcludes.isEmpty() && testIncrementalExcludes.isEmpty() )
418425
{
419426
scanner = new StaleSourceScanner( staleMillis );
420427
}
@@ -424,7 +431,9 @@ protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis )
424431
{
425432
testIncludes.add( "**/*.java" );
426433
}
427-
scanner = new StaleSourceScanner( staleMillis, testIncludes, testExcludes );
434+
Set<String> excludesIncr = new HashSet<>( testExcludes );
435+
excludesIncr.addAll( this.testIncrementalExcludes );
436+
scanner = new StaleSourceScanner( staleMillis, testIncludes, excludesIncr );
428437
}
429438

430439
return scanner;
@@ -437,7 +446,7 @@ protected SourceInclusionScanner getSourceInclusionScanner( String inputFileEndi
437446
// it's not defined if we get the ending with or without the dot '.'
438447
String defaultIncludePattern = "**/*" + ( inputFileEnding.startsWith( "." ) ? "" : "." ) + inputFileEnding;
439448

440-
if ( testIncludes.isEmpty() && testExcludes.isEmpty() )
449+
if ( testIncludes.isEmpty() && testExcludes.isEmpty() && testIncrementalExcludes.isEmpty() )
441450
{
442451
testIncludes = Collections.singleton( defaultIncludePattern );
443452
scanner = new SimpleSourceInclusionScanner( testIncludes, Collections.emptySet() );
@@ -448,7 +457,9 @@ protected SourceInclusionScanner getSourceInclusionScanner( String inputFileEndi
448457
{
449458
testIncludes.add( defaultIncludePattern );
450459
}
451-
scanner = new SimpleSourceInclusionScanner( testIncludes, testExcludes );
460+
Set<String> excludesIncr = new HashSet<>( testExcludes );
461+
excludesIncr.addAll( this.testIncrementalExcludes );
462+
scanner = new SimpleSourceInclusionScanner( testIncludes, excludesIncr );
452463
}
453464

454465
return scanner;

0 commit comments

Comments
 (0)