-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve field handling #212
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
566e601
Consider enclosing ignore annotations for fields and improve log output
Marcono1234 3837d1c
Support IgnoreJRERequirement annotation for fields
Marcono1234 e4831c9
Set SignatureChecker.ANNOTATION_FQN to constant string again
Marcono1234 36f445a
Use invoker:install to make annotations dependency available to tests
Marcono1234 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invoker.buildResult=failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
The MIT License | ||
|
||
Copyright (c) 2009 codehaus.org. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
--> | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>localdomain.localhost</groupId> | ||
<artifactId>real-test</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>fields</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>animal-sniffer-annotations</artifactId> | ||
<version>${annotationsDependencyVersion}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>2.2</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.5.1</version> | ||
<configuration> | ||
<source>@mojo.java.target@</source> | ||
<target>@mojo.java.target@</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.4.2</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>${pluginGroupId}</groupId> | ||
<artifactId>${pluginArtifactId}</artifactId> | ||
<version>${pluginVersion}</version> | ||
<executions> | ||
<execution> | ||
<phase>test</phase> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
<configuration> | ||
<signature> | ||
<groupId>org.codehaus.mojo.signature</groupId> | ||
<artifactId>java15</artifactId> | ||
<version>1.0</version> | ||
</signature> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.build.outputEncoding>UTF-8</project.build.outputEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<pluginGroupId>@project.groupId@</pluginGroupId> | ||
<pluginArtifactId>@project.artifactId@</pluginArtifactId> | ||
<pluginVersion>@project.version@</pluginVersion> | ||
<annotationsDependencyVersion>@project.version@</annotationsDependencyVersion> | ||
</properties> | ||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
animal-sniffer-maven-plugin/src/it/fields/src/main/java/localhost/Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package localhost; | ||
|
||
import java.util.Optional; | ||
|
||
public class Test { | ||
Optional<String> f; | ||
|
||
// Also include method to make sure field does not influence method detection | ||
// in any way | ||
Optional<String> test() { | ||
return null; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
animal-sniffer-maven-plugin/src/it/fields/src/main/java/localhost/TestSuppressedClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package localhost; | ||
|
||
import java.util.Optional; | ||
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; | ||
|
||
@IgnoreJRERequirement | ||
public class TestSuppressedClass { | ||
Optional<String> f; | ||
|
||
Optional<String> test() { | ||
return null; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
animal-sniffer-maven-plugin/src/it/fields/src/main/java/localhost/TestSuppressedField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package localhost; | ||
|
||
import java.util.Optional; | ||
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; | ||
|
||
public class TestSuppressedField { | ||
Optional<String> f1; | ||
@IgnoreJRERequirement | ||
Optional<String> f2; | ||
Optional<String> f3; | ||
|
||
// Also include method to make sure field does not influence method detection | ||
// in any way | ||
Optional<String> test() { | ||
return null; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
animal-sniffer-maven-plugin/src/it/fields/src/main/java/localhost/TestWithNested.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package localhost; | ||
|
||
import java.util.Optional; | ||
|
||
public class TestWithNested { | ||
Optional<String> f; | ||
|
||
Optional<String> test() { | ||
return null; | ||
} | ||
|
||
public class Nested { | ||
Optional<String> f; | ||
|
||
Optional<String> test() { | ||
return null; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...fer-maven-plugin/src/it/fields/src/main/java/localhost/TestWithNestedSuppressedClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package localhost; | ||
|
||
import java.util.Optional; | ||
import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; | ||
|
||
public class TestWithNestedSuppressedClass { | ||
@IgnoreJRERequirement | ||
public class Nested { | ||
Optional<String> f; | ||
|
||
Optional<String> test() { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
def logFile = new File( basedir, 'build.log' ) | ||
assert logFile.exists() | ||
|
||
def buildLog = logFile.getText('UTF-8') | ||
|
||
assert buildLog.contains('Test.java: Field f: Undefined reference: java.util.Optional') | ||
assert buildLog.contains('Test.java:11: Undefined reference: java.util.Optional') | ||
|
||
assert !(buildLog =~ /TestSuppressedClass.*Undefined reference/) | ||
|
||
assert buildLog.contains('TestSuppressedField.java: Field f1: Undefined reference: java.util.Optional') | ||
assert !buildLog.contains('Field f2') | ||
assert buildLog.contains('TestSuppressedField.java: Field f3: Undefined reference: java.util.Optional') | ||
assert buildLog.contains('TestSuppressedField.java:15: Undefined reference: java.util.Optional') | ||
|
||
assert buildLog.contains('TestWithNested.java: Field f: Undefined reference: java.util.Optional') | ||
assert buildLog.contains('TestWithNested.java:9: Undefined reference: java.util.Optional') | ||
assert buildLog.contains('TestWithNested.java: Field TestWithNested$Nested.f: Undefined reference: java.util.Optional') | ||
assert buildLog.contains('TestWithNested.java:16: Undefined reference: java.util.Optional') | ||
|
||
assert !(buildLog =~ /TestWithNestedSuppressedClass.*Undefined reference/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
File log = new File(basedir, 'build.log') | ||
|
||
assert log.text.contains( 'IllegalTypeReturn.java:11: Undefined reference: java.nio.file.Path' ) | ||
assert log.text.contains( 'IllegalFieldWithManipulationSample.java: Undefined reference: java.nio.file.Path' ) | ||
assert log.text.contains( 'IllegalFieldWithManipulationSample.java: Field pathField: Undefined reference: java.nio.file.Path' ) | ||
assert log.text.contains( 'IllegalFieldWithManipulationSample.java:14: Undefined reference: java.nio.file.Path' ) | ||
assert log.text.contains( 'IllegalFieldWithManipulationSample.java:18: Undefined reference: java.nio.file.Path' ) | ||
assert log.text.contains( 'IllegalFieldWithManipulationSample.java:18: Undefined reference: java.nio.file.Path java.nio.file.Path.resolve(String)' ) | ||
assert log.text.contains( 'IllegalFieldWithAccessorsSample.java: Undefined reference: java.nio.file.Path' ) | ||
assert log.text.contains( 'IllegalFieldWithAccessorsSample.java: Field pathField: Undefined reference: java.nio.file.Path' ) | ||
assert log.text.contains( 'IllegalFieldWithAccessorsSample.java:22: Undefined reference: java.nio.file.Path' ) | ||
assert log.text.contains( 'IllegalFieldSample.java: Undefined reference: java.nio.file.Paths' ) | ||
assert log.text.contains( 'IllegalFieldSample.java: Field pathsField: Undefined reference: java.nio.file.Paths' ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why
animal-sniffer-annotations
was previously not a dependency? It allows directly referring to the annotation typeIgnoreJRERequirement
inSignatureChecker
.Though if you want I can also revert this again.