khmarbaise / maven-it-extension

Experimental JUnit Jupiter Extension for writing integration tests for Maven plugins/Maven extensions/Maven Core
https://khmarbaise.github.io/maven-it-extension/
Apache License 2.0
90 stars 31 forks source link

Preparing files without an MavenJupiterExtension tests causes MalformedInputException resulting in build fails #473

Open Bukama opened 4 months ago

Bukama commented 4 months ago

Describe the bug

Running a maven build with the extension configured but without any test results in MalformedInputException.

To Reproduce Steps to reproduce the behavior:

In short:

1) Take former working Maven project 2) Add the default plugin configurations and dependencys as in the user guide of the MavenJupiterExtension 3) Add some example projects under src/test/resources-its/ 4) Run mvn clean verify

In long

  1. Best is having a full working example project which shows the code/test. This makes it possible to reproduce your issue.

That's my current setup

https://github.com/apache/maven-pmd-plugin/commit/5fae1f6a05e8e69e88bcb51b4d7871ce68c29ccd

Description

I've started setting up the setup for using the MavenJupiterExtension on the Maven PMD plugin (to then trying to recreate a bug).

Following the user guide I've added the dependencies

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>5.10.2</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.soebes.itf.jupiter.extension</groupId>
      <artifactId>itf-jupiter-extension</artifactId>
      <version>0.13.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.soebes.itf.jupiter.extension</groupId>
      <artifactId>itf-assertj</artifactId>
      <version>0.13.1</version>
      <scope>test</scope>
    </dependency>

    <!-- added to run old Junit 4 tests -->
    <dependency>
      <groupId>org.junit.vintage</groupId>
      <artifactId>junit-vintage-engine</artifactId>
      <version>5.10.2</version>
      <scope>test</scope>
    </dependency>

and plugin configuration

      <!-- Maven IT Extention  by Karl-Heinz Marbaise (needs also surefire) -->
      <plugin>
        <groupId>com.soebes.itf.jupiter.extension</groupId>
        <artifactId>itf-maven-plugin</artifactId>
        <version>0.13.1</version>
        <executions>
          <execution>
            <id>installing</id>
            <goals>
              <goal>install</goal>
              <goal>resources-its</goal>
            </goals>
            <phase>pre-integration-test</phase>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
          <systemPropertyVariables>
            <maven.version>${maven.version}</maven.version>
            <maven.home>${maven.home}</maven.home>
          </systemPropertyVariables>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

and in my already prepared Maven projects for the tests under src/test/resources-its/MPMD-386/. They are all clear Maven projects, meaning no target folder (obviously).

I have not yet written a test!

When I now run a mvn clear verify to make sure that I have no typos in XML setup, dependecy violations etc the build breaks with the following message

[ERROR] Failed to execute goal com.soebes.itf.jupiter.extension:itf-maven-plugin:0.13.1:resources-its (installing) on project maven-pmd-plugin: filtering D:\Github\Maven\maven-pmd-plugin\src\test\resources-its\MPMD-386\3_14\MultiSubFolder\subfolder\moduleA\target\pmd\pmd.cache to D:\Github\Maven\maven-pmd-plugin\target\test-classes\MPMD-386\3_14\MultiSubFolder\subfolder\moduleA\target\pmd\pmd.cache failed with MalformedInputException: Input length = 1 -> [Help 1]

While I don't understand why the extension is trying to access files from the (second in folder) project it's quite clear that the MalformedInputException is thrown as there is no pmd folder inside the target folder of that project (which seems to be generated by the extension) and therefore no pmd.cache file.

Current behavior Builds breaks with MalformedInputException

[ERROR] Failed to execute goal com.soebes.itf.jupiter.extension:itf-maven-plugin:0.13.1:resources-its (installing) on project maven-pmd-plugin: filtering D:\Github\Maven\maven-pmd-plugin\src\test\resources-its\MPMD-386\3_14\MultiSubFolder\subfolder\moduleA\target\pmd\pmd.cache to D:\Github\Maven\maven-pmd-plugin\target\test-classes\MPMD-386\3_14\MultiSubFolder\subfolder\moduleA\target\pmd\pmd.cache failed with MalformedInputException: Input length = 1 -> [Help 1]

Expected behavior Build runs without problems as no IT has yet been created which could be picked up by the extension.

*Log files/Information

See To Reproduce

Full Working Example To follow your issue it is really needed to have a full working example of the behaviour which shows the problem otherwise it's really hard to find the problem or even more to fix issues.

https://github.com/apache/maven-pmd-plugin/commit/5fae1f6a05e8e69e88bcb51b4d7871ce68c29ccd

The used versions The version of tools you have used.

Maven home: C:\apache-maven-4.0.0-beta-3 Java version: 17.0.6, vendor: Eclipse Adoptium, runtime: C:\JDK\Java17 Default locale: de_DE, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "winnt"

IDE: command line ITF: 0.13.1 (newest as time of writing)

GiuseppeMP commented 1 week ago

@Bukama I had this issue before and discovered that my IDE was building the test projects and creating a target folder inside them. I deleted the target folder from each project, and the error went away.