简体   繁体   中英

No .class file in the jar when adding a META-INF/services directory

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 services directory 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?

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.

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 !

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM