[jboss-jira] [JBoss JIRA] (DROOLS-495) kie maven plugin, packaging kjar, test resources file not resolved
Petr Široký (JIRA)
issues at jboss.org
Fri Jul 25 13:19:29 EDT 2014
[ https://issues.jboss.org/browse/DROOLS-495?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12988095#comment-12988095 ]
Petr Široký commented on DROOLS-495:
------------------------------------
Hello,
I believe the root cause is here: https://github.com/droolsjbpm/drools/blob/master/kie-maven-plugin/src/main/resources/META-INF/plexus/components.xml. The file lists the phases that should be executed during the build and I think the _process-test-resources_ (which copies the test resources into target/test-classes) is missing. I will create a PR with the change once I test the changes locally.
In the meantime you can use the following workaround (defining the _resources:testResources_ manually in pom.xml):
{code:xml}
<build>
....
<plugins>
....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-test-resources</id>
<phase>process-test-resources</phase>
<goals>
<goal>testResources</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
{code}
> kie maven plugin, packaging kjar, test resources file not resolved
> ------------------------------------------------------------------
>
> Key: DROOLS-495
> URL: https://issues.jboss.org/browse/DROOLS-495
> Project: Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Affects Versions: 6.1.0.Beta3, 6.1.0.CR2
> Reporter: Matteo Mortari
> Assignee: Mark Proctor
> Attachments: 20140521.drools6test.testresources.zip
>
>
> I understand the idiomatic way for a drools Kie rule Maven project to be built, as shown in the [example|https://github.com/droolsjbpm/drools/blob/master/kie-maven-plugin-example/pom.xml], is to include in the pom:
> * Kie Maven plugin
> * set packaging to {{kjar}}
> However, normally the file resources available under
> {noformat}
> src/
> test/
> resources/
> aresource.txt
> {noformat}
> 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:
> {code:title=AppTest.java|borderStyle=solid}
> @Test
> public void testFindTheFile() {
> URL resource = getClass().getResource("/aresource.txt");
> assertNotNull(resource);
> }
> {code}
> 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}}
> {code:xml|title=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>
> {code}
> Thank you in advance for your feedback accordingly;
> Ciao
> Matteo
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
More information about the jboss-jira
mailing list