Search code examples
javamaven-2compilationpackage

Maven: Compiling package-info.java to package-info.class?


I have package-info.java in my package, Hibernate wants it for some features (programatic entity scanning).

However, mvn package does not result in package-info.class being in classes/ thus not in the artifact.

How can I force that happening?

mvn -v
Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
Java version: 1.6.0_26
Java home: /usr/lib/jvm/java-6-sun-1.6.0.26/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.35-30-generic" arch: "amd64" Family: "unix"

Solution

  • The error was that the package-info.java must have any annotation with Retention=RUNTIME to compile into a class. Otherwise, JDK 6 omits it.
    I used @Deprecated which is the only one in Java SE (and I didn't want to introduce an annotation just because of that).

    @Deprecated
    package cz.zizka.ondra.packageinfo.test