Question

I am trying to write some extra data to my manifest.mf via the pom.xml but for some reason it is remaining blank.... I am a complete newbie at java so am going to write all my steps down here .. no matter how stupid this makes me look as i have no idea what i am doing so any pointers would be great...

This is the build part of my pom.xml

<build>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.4</version>
        <configuration>
            <archive>
                <manifestFile>
                    ${basedir}/src/main/resources/META-INF/MANIFEST.MF
                </manifestFile>
                <manifest>
                    <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                    <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                </manifest>
                <manifestEntries>
                    <Test>I am a test</Test>
                </manifestEntries>
            </archive>
        </configuration>
    </plugin>
  </plugins>
</build>

I have manually created the file MANIFEST.MF inside the src/main/resources/META-INF file and left it blank expecting it to writing during the build.

I run mvn clean package

I go into the target/resources/classes/META-INF dir and open MANIFEST.MF its blank. When i go to the target/ and do

java -jar myTest.jar

the result is

no main manifest attribute, in myTest.jar

Would anyone please be able to tell me (very gently) what i am doing wrong

:D

thanks in advance

Was it helpful?

Solution

The maven pom.xml section looks good to me. You might want to use winzip or winrar to open the myTest.jar and check the MANIFEST.MF file inside the jar file under the target folder. Very likely your MANIFEST.MF file has already merged with the entries such as Implementation-Version for your project. The reason that target/resources/classes/META-INF/MANIFEST.MF is blank is because the merge has not happened yet. Maven at that time simply copied the MANIFEST.MF file you provided to the target folder. When you run java -jar myTest.jar, you got result "no main manifest attribute". That's because you did not specify <mainClass/> within the <manifest> section. If you do so, it will add a Main-Class entry in the MANIFEST.MF file, which will be the main class to be executed when you do java -jar myTest.jar

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top