2

I've just started to use Maven and I am having trouble creating a JAR of all my classes. In fact, I have to include a service located at WEB-INF/services/javax.annotation.processing.Processor

I've tested different issues with this problem and it appears that when I remove the /services directory, the JAR contains all the .class files.

I read that it could be a wrong Maven folder structure but the problem occurs just when I have the servicesdirectory present.

Here is an extract of my pom.xml file working with resources:

<resource>
    <directory>${myRessources}</directory>
        <includes>
            <include>META-INF/**/*</include>
         </includes>
</resource>

The maven console tell me that the resource is successfully copied so I assume this part is not the problem.

Any ideas?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
MadJlzz
  • 767
  • 2
  • 13
  • 35
  • Where are your source files located? – Thomas Aug 26 '14 at 12:25
  • They are located in src/main/java ; my resources are located in src/main/resources so the META-INF directory is in src/main/resources/META-INF/services/* – MadJlzz Aug 26 '14 at 12:27
  • then I dont think you need to explicitly define the include tag – sanbhat Aug 26 '14 at 12:29
  • 2
    @JuriexFF can you please post your complete pom.xml? Can you also check that the class files are generated in the `target/classes` directory? – Thomas Aug 26 '14 at 13:04

3 Answers3

2

Hey you want to use something like this:

<build>
  <sourceDirectory>src/main/java (or your .java you want to compile)</sourceDirectory>
   <resources>
    <resource>
     <directory>src/main/resources/META-INF/</directory>
     <targetPath>META-INF</targetPath>
    </resource>
   </resources>
</build>

The sourceDirectory tells maven what to compile and put in the target folder (and in the jar). Then the resource says take everything in my META-INF/ folder and put it in the META-INF folder of the jar file.

user2615862
  • 149
  • 1
  • 10
1

I investigate and solved the problem : it was a bug --> http://jira.codehaus.org/browse/MCOMPILER-97 I add the compiler option -proc:none and it works fine now. Hope it helps other people !

MadJlzz
  • 767
  • 2
  • 13
  • 35
0

What can lead you to the solution either speaking of *.jar or *.war files is that after the creation of the archive file, open it with WinRAR for example, and examine its content.

After this, you can include the necessary resources in the pom.xml file, as it was mentioned here before.

martoncsukas
  • 2,077
  • 20
  • 23