From f449bf1ec88a3cbebadadde0b369108f5585218d Mon Sep 17 00:00:00 2001
From: exiahuang <exia.huang@outlook.com>
Date: Sun, 26 May 2024 17:17:15 +0900
Subject: [PATCH] fix outputDirectory not work at running spotbugs:spotbugs
 goal

---
 src/it/html-report/pom.xml                                     | 1 +
 src/it/html-report/verify.groovy                               | 2 +-
 src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsMojo.groovy | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/it/html-report/pom.xml b/src/it/html-report/pom.xml
index cfe54134..5405d667 100644
--- a/src/it/html-report/pom.xml
+++ b/src/it/html-report/pom.xml
@@ -37,6 +37,7 @@
         <configuration>
           <xmlOutput>true</xmlOutput>
           <htmlOutput>true</htmlOutput>
+          <outputDirectory>target/test-output-directory</outputDirectory>
           <failOnError>false</failOnError>
           <debug>@spotbugsTestDebug@</debug>
           <threshold>High</threshold>
diff --git a/src/it/html-report/verify.groovy b/src/it/html-report/verify.groovy
index 422b6a72..227a4097 100644
--- a/src/it/html-report/verify.groovy
+++ b/src/it/html-report/verify.groovy
@@ -13,5 +13,5 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-File spotbugsHtml =  new File(basedir, 'target/spotbugs.html')
+File spotbugsHtml =  new File(basedir, 'target/test-output-directory/spotbugs.html')
 assert spotbugsHtml.exists()
diff --git a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsMojo.groovy b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsMojo.groovy
index 20bc5aff..1358ce5c 100644
--- a/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsMojo.groovy
+++ b/src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsMojo.groovy
@@ -1098,7 +1098,7 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
 
         log.debug("****** SpotBugsMojo executeSpotbugs *******")
 
-        File htmlTempFile = new File("${project.build.directory}/spotbugs.html")
+        File htmlTempFile = new File("${outputDirectory}/spotbugs.html")
         if (htmlOutput) {
             forceFileCreation(htmlTempFile)
         }