-1

I am creating a jar out of my codebase with selectes packages. Also i need the xml files to be moved to META-INF folder. But i dont see that happening though my jar gets created.

<build>
<resources>
    <resource>
        <directory>${project.basedir}/src</directory>
        <includes>
            <include>jboss-ejb3.xml</include>
            <include>ejb-jar.xml</include>
        </includes>
        <targetPath>${project.build.outputDirectory}/META-INF</targetPath>
    </resource>
</resources>

 <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.1.1</version>
        <configuration>
            <includes>
                <include>com/**/server/*EJB.class</include>
                <include>com/**/common/*Remote.class</include>
            </includes>
            <!-- <archive> -->
                <!-- <addMavenDescriptor>false</addMavenDescriptor> -->
            <!-- </archive> -->
        </configuration>
    </plugin>
</plugins>

When i use Maven-resource-plugin i could see the META-INF folder generated in target folder. But not seeing the same inside jar.

Vishwa Ratna
  • 5,567
  • 5
  • 33
  • 55
harimper
  • 1
  • 2
  • Why not just place them in `src/main/resources/META-INF`? Then they will be automatically added., no need to add the resources plugin. – M. Deinum Apr 15 '19 at 10:23
  • i tried that as well. That perfectly works fine when i create a jar without using any file filters (). But when i filter certain packages, then META-INF does not gets moved to jar. – harimper Apr 15 '19 at 10:42
  • When you filter with include you must add everything you want to include, including `META-INF`... If something doesn't match the include filter it will be excluded. But why do you need an include filter in the first place? Shouldn't everything simply be part of the jar? – M. Deinum Apr 15 '19 at 10:43
  • Have tried that too. But same outcome. i used as below. src/main/resources/META-INF/jboss-deployment-structure.xml src/main/resources/META-INF/jboss-ejb3.xml com/**/server/*EJB.class com/**/common/*Remote.class – harimper Apr 15 '19 at 10:51
  • You should have `META-INF/**` NOT `src/main/resources/META-INF` and then it should be included. But again why do you need an include filter in the first place. It filters the `target` directory NOT the sources. – M. Deinum Apr 15 '19 at 10:51
  • oh Yes!! got it. its working now. Thanks to you. I am currently migrating a legacy project from ANT based build to Maven. Here from a single codebase they are creating multiple jars. Like a, b, c classes to one jar, x, y, z classes into another and so on. Hence using the filters. – harimper Apr 15 '19 at 10:58

1 Answers1

0

This was solved by using <include>META-INF/**</include> as suggested by user M.Deinum

harimper
  • 1
  • 2