Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-495

kie maven plugin, packaging kjar, test resources file not resolved

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 6.1.0.Beta3, 6.1.0.CR2
    • Fix Version/s: 6.1.0.Final
    • Component/s: None
    • Labels:
      None

      Description

      I understand the idiomatic way for a drools Kie rule Maven project to be built, as shown in the example, is to include in the pom:

      • Kie Maven plugin
      • set packaging to kjar

      However, normally the file resources available under

      src/
         test/
            resources/
               aresource.txt
      

      should be available while running mvn test

      However I noticed if packaging is set to kjar, this fails. It is working as expected if instead the packaging is set to the standard jar

      Consider the following attached example project to replicate the issue. It contains the 'aresource.txt' file in the standard Maven layout directory src/test/resources as shown above. However the following simple test fails:

      AppTest.java
      @Test
      public void testFindTheFile() {
      	URL resource = getClass().getResource("/aresource.txt");
      	assertNotNull(resource);
      }
      

      Setting instead the project packaging to the standard jar instead, pass the test, and in fact it can be noticed the 'aresource.txt' file is available under target/test-classes directory.

      Extract of the pom failing the test due to packaging set to kjar

      pom.xml
      <project ...>
        <modelVersion>4.0.0</modelVersion>
      
        <groupId>com.acme</groupId>
        <artifactId>drools6test.testresources</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        
        <packaging>kjar</packaging>
        
      <!-- ... -->
        
      	<dependencyManagement>
      		<dependencies>
      			<dependency>
      				<groupId>org.drools</groupId>
      				<artifactId>drools-bom</artifactId>
      				<type>pom</type>
      				<version>6.1.0.Beta3</version>
      				<scope>import</scope>
      			</dependency>
      		</dependencies>
      	</dependencyManagement>
      	
      <!-- ... -->
      
      	<build>
      		<finalName>drools6test.testresources</finalName>
      		<plugins>
      			<plugin>
      				<groupId>org.kie</groupId>
      				<artifactId>kie-maven-plugin</artifactId>
      				<version>6.1.0.Beta3</version>
      				<extensions>true</extensions>
      			</plugin>
      		</plugins>
      </project>
      

      Thank you in advance for your feedback accordingly;
      Ciao
      Matteo

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                psiroky Petr Široký
                Reporter:
                tari_manga Matteo Mortari
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: