Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate MANIFEST.MF file during compile phase

Standard way - using maven-jar-plugin - generates manifest file only during package phase and directly into jar file.

What I need is to generate manifest during compile phase and to be available in <target>/classes/META-INF.

My goal is to be able to read this manifest file in project running in debug mode in IntelliJ Idea. (Idea resolves in-project jar dependencies from <target>/classes instead of from <target>/*.jar - for hot-swap purpose).

The only solution I know of so far is to actually create my own MANIFEST.MF in src/main/java/resources/META-INF and let it be filtered+copied during resources phase. But I want to avoid this solution, I want the manifest to be generated standard way using <archive> configuration in pom file.

like image 293
Petr Újezdský Avatar asked Jan 08 '16 09:01

Petr Újezdský


1 Answers

You can do this with maven-bundle-plugin.

   <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
            <execution>
                <id>bundle-manifest</id>
                <phase>process-classes</phase>
                <goals>
                    <goal>manifest</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <archive>
                <index>true</index>
                <manifest>
                    <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                    <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                </manifest>
                <manifestEntries>
                    <Implementation-URL>${project.url}</Implementation-URL>
                    <Java-Version>${java.version}</Java-Version>
                    <Java-Vendor>${java.vendor}</Java-Vendor>
                    <Os-Name>${os.name}</Os-Name>
                    <Os-Arch>${os.arch}</Os-Arch>
                    <Os-Version>${os.version}</Os-Version>
                    <Scm-Url>${project.scm.url}</Scm-Url>
                    <Scm-Connection>${project.scm.connection}</Scm-Connection>
                </manifestEntries>
            </archive>
        </configuration>
    </plugin>
like image 54
frekele Avatar answered Sep 18 '22 17:09

frekele