Skip to content

Commit

Permalink
[MCOMPILER-500] add some parameter to pattern from stale source calcu…
Browse files Browse the repository at this point in the history
…lation (#141)

Signed-off-by: Olivier Lamy <[email protected]>
  • Loading branch information
olamy authored Jul 26, 2022
1 parent cdfeb52 commit a522b31
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 8 deletions.
21 changes: 21 additions & 0 deletions src/it/MCOMPILER-500-package-info-incr/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

invoker.goals = clean compile
invoker.buildResult = success
invoker.goals.2 = compile
invoker.buildResult.2 = success
50 changes: 50 additions & 0 deletions src/it/MCOMPILER-500-package-info-incr/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<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/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin-it-package-info-incr</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>@pom.version@</version>
<configuration>
<createMissingPackageInfoClass>false</createMissingPackageInfoClass>
<incrementalExcludes>
<incrementalExclude>**/package-info.java</incrementalExclude>
</incrementalExcludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package dummy;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/


public class Person {
private long id;
private String name;

public long getId() {
return id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package dummy.foo;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/


public class Person {
private long id;
private String name;

public long getId() {
return id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* This is the package javadoc
*/
package dummy;
27 changes: 27 additions & 0 deletions src/it/MCOMPILER-500-package-info-incr/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
def logFile = new File( basedir, 'build.log' )
assert logFile.exists()
content = logFile.text

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


18 changes: 14 additions & 4 deletions src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ public class CompilerMojo
@Parameter
private Set<String> excludes = new HashSet<>();

/**
* A list of exclusion filters for the incremental calculation.
* @since 3.11
*/
@Parameter
private Set<String> incrementalExcludes = new HashSet<>();

/**
* <p>
* Specify where to place generated source files created by annotation processing. Only applies to JDK 1.6+
Expand Down Expand Up @@ -387,7 +394,7 @@ private List<File> getCompileClasspathElements( MavenProject project )

protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis )
{
if ( includes.isEmpty() && excludes.isEmpty() )
if ( includes.isEmpty() && excludes.isEmpty() && incrementalExcludes.isEmpty() )
{
return new StaleSourceScanner( staleMillis );
}
Expand All @@ -397,7 +404,9 @@ protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis )
includes.add( "**/*.java" );
}

return new StaleSourceScanner( staleMillis, includes, excludes );
Set<String> excludesIncr = new HashSet<>( excludes );
excludesIncr.addAll( this.incrementalExcludes );
return new StaleSourceScanner( staleMillis, includes, excludesIncr );
}

protected SourceInclusionScanner getSourceInclusionScanner( String inputFileEnding )
Expand All @@ -409,8 +418,9 @@ protected SourceInclusionScanner getSourceInclusionScanner( String inputFileEndi
{
includes.add( defaultIncludePattern );
}

return new SimpleSourceInclusionScanner( includes, excludes );
Set<String> excludesIncr = new HashSet<>( excludes );
excludesIncr.addAll( excludesIncr );
return new SimpleSourceInclusionScanner( includes, excludesIncr );
}

protected String getSource()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ public class TestCompilerMojo
@Parameter
private Set<String> testExcludes = new HashSet<>();

/**
* A list of exclusion filters for the incremental calculation.
* @since 3.11
*/
@Parameter
private Set<String> testIncrementalExcludes = new HashSet<>();

/**
* The -source argument for the test Java compiler.
*
Expand Down Expand Up @@ -414,7 +421,7 @@ protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis )
{
SourceInclusionScanner scanner;

if ( testIncludes.isEmpty() && testExcludes.isEmpty() )
if ( testIncludes.isEmpty() && testExcludes.isEmpty() && testIncrementalExcludes.isEmpty() )
{
scanner = new StaleSourceScanner( staleMillis );
}
Expand All @@ -424,7 +431,9 @@ protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis )
{
testIncludes.add( "**/*.java" );
}
scanner = new StaleSourceScanner( staleMillis, testIncludes, testExcludes );
Set<String> excludesIncr = new HashSet<>( testExcludes );
excludesIncr.addAll( this.testIncrementalExcludes );
scanner = new StaleSourceScanner( staleMillis, testIncludes, excludesIncr );
}

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

if ( testIncludes.isEmpty() && testExcludes.isEmpty() )
if ( testIncludes.isEmpty() && testExcludes.isEmpty() && testIncrementalExcludes.isEmpty() )
{
testIncludes = Collections.singleton( defaultIncludePattern );
scanner = new SimpleSourceInclusionScanner( testIncludes, Collections.emptySet() );
Expand All @@ -448,7 +457,9 @@ protected SourceInclusionScanner getSourceInclusionScanner( String inputFileEndi
{
testIncludes.add( defaultIncludePattern );
}
scanner = new SimpleSourceInclusionScanner( testIncludes, testExcludes );
Set<String> excludesIncr = new HashSet<>( testExcludes );
excludesIncr.addAll( this.testIncrementalExcludes );
scanner = new SimpleSourceInclusionScanner( testIncludes, excludesIncr );
}

return scanner;
Expand Down

0 comments on commit a522b31

Please sign in to comment.