@@ -870,6 +870,7 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
870
870
private ArrayList<String > getSpotbugsArgs (File htmlTempFile , File xmlTempFile , File sarifTempFile ) {
871
871
ResourceHelper resourceHelper = new ResourceHelper (log, spotbugsXmlOutputDirectory, resourceManager)
872
872
def args = new ArrayList<String > ()
873
+ def auxClasspathFile = createSpotbugsAuxClasspathFile()
873
874
874
875
if (userPrefs) {
875
876
log. debug(" Adding User Preferences File -> ${ userPrefs} " )
@@ -888,6 +889,11 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
888
889
args << " -sarif=" + sarifTempFile. getAbsolutePath()
889
890
}
890
891
892
+ if (auxClasspathFile) {
893
+ args << " -auxclasspathFromFile"
894
+ args << auxClasspathFile. getAbsolutePath()
895
+ }
896
+
891
897
args << " -projectName"
892
898
args << " ${ project.name} "
893
899
@@ -1022,42 +1028,37 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
1022
1028
}
1023
1029
1024
1030
/**
1025
- * Get the Spotbugs AuxClasspath.
1031
+ * Create the Spotbugs AuxClasspath file .
1026
1032
*
1027
1033
*/
1028
- private String getSpotbugsAuxClasspath () {
1034
+ private File createSpotbugsAuxClasspathFile () {
1029
1035
def auxClasspathElements
1030
1036
1031
- if (classFilesDirectory. exists() && classFilesDirectory. isDirectory()) {
1032
- auxClasspathElements = project. compileClasspathElements
1033
- }
1034
-
1035
1037
if (testClassFilesDirectory. exists() && testClassFilesDirectory. isDirectory() && includeTests) {
1036
1038
auxClasspathElements = project. testClasspathElements
1039
+ } else if (classFilesDirectory. exists() && classFilesDirectory. isDirectory()) {
1040
+ auxClasspathElements = project. compileClasspathElements
1037
1041
}
1038
1042
1039
- def auxClasspath = " "
1043
+ File auxClasspathFile = null
1040
1044
1041
1045
if (auxClasspathElements) {
1046
+ auxClasspathFile = File . createTempFile(" auxclasspath" , " .tmp" )
1047
+ auxClasspathFile. deleteOnExit()
1042
1048
log. debug(" AuxClasspath Elements ->" + auxClasspathElements)
1043
1049
1044
1050
def auxClasspathList = auxClasspathElements. findAll { project. build. outputDirectory != it. toString() }
1045
1051
if (auxClasspathList. size() > 0 ) {
1046
-
1047
- auxClasspath + = File . pathSeparator
1048
-
1049
1052
log. debug(" Last AuxClasspath is ->" + auxClasspathList[auxClasspathList. size() - 1 ])
1050
1053
1051
1054
auxClasspathList. each() { auxClasspathElement ->
1052
1055
log. debug(" Adding to AuxClasspath ->" + auxClasspathElement. toString())
1053
- auxClasspath + = auxClasspathElement. toString() + File . pathSeparator
1056
+ auxClasspathFile << auxClasspathElement. toString() + " \n "
1054
1057
}
1055
1058
}
1056
1059
}
1057
1060
1058
- log. debug(" AuxClasspath is ->" + auxClasspath)
1059
-
1060
- return auxClasspath
1061
+ return auxClasspathFile
1061
1062
}
1062
1063
1063
1064
/**
@@ -1142,7 +1143,7 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
1142
1143
effectiveEncoding = sourceEncoding
1143
1144
}
1144
1145
1145
- ant. java(classname : " edu.umd.cs.findbugs.FindBugs2" , inputstring : getSpotbugsAuxClasspath(), fork : " ${ fork} " , failonerror : " true" , clonevm : " false" , timeout : " ${ timeout} " , maxmemory : " ${ maxHeap} m" ) {
1146
+ ant. java(classname : " edu.umd.cs.findbugs.FindBugs2" , fork : " ${ fork} " , failonerror : " true" , clonevm : " false" , timeout : " ${ timeout} " , maxmemory : " ${ maxHeap} m" ) {
1146
1147
1147
1148
log. debug(" File Encoding is " + effectiveEncoding)
1148
1149
0 commit comments