-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,114 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# AnimalSniffer plugin usage examples | ||
|
||
All projects intentionally contain errors to demonstrate error reporting | ||
|
||
* [Java](java) | ||
* [Groovy](groovy) | ||
* [Kotlin](kotlin) | ||
* [Scala](scala) | ||
|
||
[Java](java) example shows also validation with android signature (would be the same for other examples) | ||
|
||
[Build signature examples](buildSignature) |
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,3 @@ | ||
wrapper { | ||
gradleVersion = '7.6' | ||
} |
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,10 @@ | ||
# Signature creation examples | ||
|
||
Examples of building custom signature files for checks | ||
|
||
* [Classes](fromClasses) - signature from project classes | ||
* [Jars](fromJars) - signature from project jars (configuration) | ||
* [Signatures](fromSignatures) - signature from other signatures | ||
* [Mixed](fromMix) - signature from different sources | ||
|
||
See [wiki for more details](https://github.com/xvik/gradle-animalsniffer-plugin/wiki/Library-signatures) |
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,25 @@ | ||
# Signatures build from project classes | ||
|
||
``` | ||
> Task :buildSignature:fromClasses:compileJava | ||
> Task :buildSignature:fromClasses:processResources NO-SOURCE | ||
> Task :buildSignature:fromClasses:classes | ||
> Task :buildSignature:fromClasses:jar | ||
> Task :buildSignature:fromClasses:assemble | ||
> Task :buildSignature:fromClasses:animalsnifferMain UP-TO-DATE | ||
> Task :buildSignature:fromClasses:compileTestJava NO-SOURCE | ||
> Task :buildSignature:fromClasses:processTestResources NO-SOURCE | ||
> Task :buildSignature:fromClasses:testClasses UP-TO-DATE | ||
> Task :buildSignature:fromClasses:animalsnifferTest NO-SOURCE | ||
> Task :buildSignature:fromClasses:test NO-SOURCE | ||
> Task :buildSignature:fromClasses:check UP-TO-DATE | ||
> Task :buildSignature:fromClasses:animalsnifferSignature | ||
> Task :buildSignature:fromClasses:printSignature | ||
Signature mySignature.sig (286.0 bytes) contains 1 classes | ||
sample 1 | ||
> Task :buildSignature:fromClasses:build | ||
BUILD SUCCESSFUL in 369ms | ||
``` |
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,25 @@ | ||
plugins { | ||
id 'java' | ||
id 'ru.vyarus.animalsniffer' version '1.6.0' | ||
} | ||
|
||
animalsnifferSignature { | ||
// debug = true | ||
// signature from project classes | ||
files sourceSets.main.output | ||
// by default project name | ||
outputName 'mySignature' | ||
} | ||
|
||
repositories { mavenCentral()} | ||
dependencies { | ||
implementation "org.codehaus.mojo:animal-sniffer-annotations:1.14" | ||
implementation 'org.slf4j:slf4j-api:1.7.25' | ||
} | ||
|
||
tasks.register('printSignature', ru.vyarus.gradle.plugin.animalsniffer.info.SignatureInfoTask) { | ||
signature = tasks.animalsnifferSignature.outputFiles | ||
depth = 2 | ||
} | ||
|
||
tasks.build.dependsOn 'printSignature' |
16 changes: 16 additions & 0 deletions
16
examples/buildSignature/fromClasses/src/main/java/sample/Sample.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,16 @@ | ||
package sample; | ||
|
||
import org.slf4j.LoggerFactory; | ||
|
||
public class Sample { | ||
|
||
private String sample; | ||
|
||
public Sample(String sample) { | ||
this.sample = sample; | ||
} | ||
|
||
public static void main(String[] args) { | ||
LoggerFactory.getLogger(Sample.class); | ||
} | ||
} |
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,31 @@ | ||
# Signatures build from project jars | ||
|
||
``` | ||
> Task :buildSignature:fromJars:compileJava NO-SOURCE | ||
> Task :buildSignature:fromJars:processResources NO-SOURCE | ||
> Task :buildSignature:fromJars:classes UP-TO-DATE | ||
> Task :buildSignature:fromJars:jar | ||
> Task :buildSignature:fromJars:assemble | ||
> Task :buildSignature:fromJars:animalsnifferMain NO-SOURCE | ||
> Task :buildSignature:fromJars:compileTestJava NO-SOURCE | ||
> Task :buildSignature:fromJars:processTestResources NO-SOURCE | ||
> Task :buildSignature:fromJars:testClasses UP-TO-DATE | ||
> Task :buildSignature:fromJars:animalsnifferTest NO-SOURCE | ||
> Task :buildSignature:fromJars:test NO-SOURCE | ||
> Task :buildSignature:fromJars:check UP-TO-DATE | ||
> Task :buildSignature:fromJars:animalsnifferSignature | ||
> Task :buildSignature:fromJars:printSignature | ||
Signature mySignature.sig (20.7 Kb) contains 332 classes | ||
org.junit 258 | ||
org.hamcrest 45 | ||
junit.framework 17 | ||
junit.extensions 6 | ||
junit.runner 3 | ||
junit.textui 2 | ||
org.codehaus 1 | ||
> Task :buildSignature:fromJars:build | ||
BUILD SUCCESSFUL in 338ms | ||
``` |
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,25 @@ | ||
plugins { | ||
id 'java' | ||
id 'ru.vyarus.animalsniffer' version '1.6.0' | ||
} | ||
|
||
animalsnifferSignature { | ||
// debug = true | ||
// signature from project jars | ||
files configurations.compileClasspath | ||
// by default project name | ||
outputName 'mySignature' | ||
} | ||
|
||
repositories { mavenCentral()} | ||
dependencies { | ||
implementation 'junit:junit:4.12' | ||
implementation "org.codehaus.mojo:animal-sniffer-annotations:1.14" | ||
} | ||
|
||
tasks.register('printSignature', ru.vyarus.gradle.plugin.animalsniffer.info.SignatureInfoTask) { | ||
signature = tasks.animalsnifferSignature.outputFiles | ||
depth = 2 | ||
} | ||
|
||
tasks.build.dependsOn 'printSignature' |
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,95 @@ | ||
# Signatures build from different sources | ||
|
||
``` | ||
> Task :buildSignature:fromMix:compileJava | ||
> Task :buildSignature:fromMix:processResources NO-SOURCE | ||
> Task :buildSignature:fromMix:classes | ||
> Task :buildSignature:fromMix:jar | ||
> Task :buildSignature:fromMix:assemble | ||
> Task :buildSignature:fromMix:animalsnifferMain | ||
> Task :buildSignature:fromMix:compileTestJava NO-SOURCE | ||
> Task :buildSignature:fromMix:processTestResources NO-SOURCE | ||
> Task :buildSignature:fromMix:testClasses UP-TO-DATE | ||
> Task :buildSignature:fromMix:animalsnifferTest NO-SOURCE | ||
> Task :buildSignature:fromMix:test NO-SOURCE | ||
> Task :buildSignature:fromMix:check | ||
> Task :buildSignature:fromMix:animalsnifferSignature | ||
> Task :buildSignature:fromMix:printSignature | ||
Signature mySignature.sig (1.7 Mb) contains 18348 classes | ||
com.sun 7115 | ||
javax.swing 1781 | ||
sun.awt 771 | ||
java.util 662 | ||
sun.nio 640 | ||
sun.security 632 | ||
java.awt 561 | ||
org.omg 538 | ||
javax.xml 395 | ||
sun.io 331 | ||
sun.java2d 259 | ||
javax.management 250 | ||
java.lang 239 | ||
sun.util 235 | ||
sun.management 222 | ||
sun.text 222 | ||
sun.net 219 | ||
java.security 212 | ||
sun.rmi 157 | ||
javax.print 156 | ||
java.beans 155 | ||
sun.misc 152 | ||
java.nio 150 | ||
org.w3c 150 | ||
sun.reflect 143 | ||
sun.org 130 | ||
java.io 126 | ||
java.net 122 | ||
sun.font 122 | ||
javax.naming 115 | ||
sun.swing 104 | ||
javax.security 99 | ||
sun.print 96 | ||
javax.imageio 89 | ||
java.rmi 77 | ||
java.text 71 | ||
javax.sound 71 | ||
javax.crypto 63 | ||
sun.applet 63 | ||
org.jcp 55 | ||
java.sql 51 | ||
javax.lang 48 | ||
javax.net 48 | ||
javax.sql 48 | ||
sun.jdbc 42 | ||
org.xml 39 | ||
org.slf4j 34 | ||
javax.accessibility 27 | ||
javax.activation 27 | ||
sun.jkernel 27 | ||
sun.tools 24 | ||
javax.tools 22 | ||
javax.annotation 19 | ||
javax.rmi 17 | ||
javax.smartcardio 16 | ||
javax.jws 14 | ||
sun.audio 14 | ||
javax.script 13 | ||
sun.beans 12 | ||
sun.dc 11 | ||
java.math 10 | ||
org.ietf 8 | ||
javax.transaction 6 | ||
java.applet 5 | ||
sun.corba 4 | ||
sun.instrument 4 | ||
javax.activity 3 | ||
sunw.util 2 | ||
org.codehaus 1 | ||
sample 1 | ||
sunw.io 1 | ||
> Task :buildSignature:fromMix:build | ||
BUILD SUCCESSFUL in 1s | ||
``` |
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,33 @@ | ||
plugins { | ||
id 'java' | ||
id 'ru.vyarus.animalsniffer' version '1.6.0' | ||
} | ||
|
||
// just an example of custom configuration usage, it might be defailt 'signature' configuration, but it would affect | ||
// animalsniffer check task | ||
configurations.create('buildSignatures') | ||
|
||
animalsnifferSignature { | ||
// debug = true | ||
// signature from project classes | ||
files sourceSets.main.output | ||
files configurations.compileClasspath | ||
signatures configurations.buildSignatures | ||
// by default project name | ||
outputName 'mySignature' | ||
} | ||
|
||
repositories { mavenCentral()} | ||
dependencies { | ||
buildSignatures 'org.codehaus.mojo.signature:java16-sun:1.0@signature' | ||
|
||
implementation "org.codehaus.mojo:animal-sniffer-annotations:1.14" | ||
implementation 'org.slf4j:slf4j-api:1.7.25' | ||
} | ||
|
||
tasks.register('printSignature', ru.vyarus.gradle.plugin.animalsniffer.info.SignatureInfoTask) { | ||
signature = tasks.animalsnifferSignature.outputFiles | ||
depth = 2 | ||
} | ||
|
||
tasks.build.dependsOn 'printSignature' |
16 changes: 16 additions & 0 deletions
16
examples/buildSignature/fromMix/src/main/java/sample/Sample.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,16 @@ | ||
package sample; | ||
|
||
import org.slf4j.LoggerFactory; | ||
|
||
public class Sample { | ||
|
||
private String sample; | ||
|
||
public Sample(String sample) { | ||
this.sample = sample; | ||
} | ||
|
||
public static void main(String[] args) { | ||
LoggerFactory.getLogger(Sample.class); | ||
} | ||
} |
Oops, something went wrong.