I want to move a startup MBEAN file (startup-client-service.xml) from my EJB >META-INF,  to EAR> META-INF folder. I tried with the maven-resources-plugin plugin but it just copy the file from EJB >META-INF to Target in ear folder. But in built ear the startup-client-service.xml file is not available in META-INF
How can I move my startup file to META-INF into ear > META-INF ?
This is the pom file of ear.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>com.testapp</groupId>
    <artifactId>my-client-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<name>Test app EAR</name>
<artifactId>my-client-ear</artifactId>
<packaging>ear</packaging>
<dependencies>
    <dependency>
        <groupId>com.testapp</groupId>
        <artifactId>my-client-ejb</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <type>ejb</type>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.8</version>
            <configuration>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <modules>
                </modules>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>META-INF</outputDirectory>
                        <resources>
                            <resource>
                                <directory>${project.parent.basedir}/ejb/src/main/resources/META-INF</directory>
                                <filtering>true</filtering>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.apache.maven.plugins
                                    </groupId>
                                    <artifactId>
                                        maven-ear-plugin
                                    </artifactId>
                                    <versionRange>
                                        [2.8,)
                                    </versionRange>
                                    <goals>
                                        <goal>
                                            generate-application-xml
                                        </goal>                                         
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
<profiles>
    <profile>
        <id>copy_bundle</id>
        <properties>
            <install.dir>${jboss.dir}\server\default\deploy</install.dir>
        </properties>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>Copying bundle to destination folder</id>
                            <phase>package</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                                <tasks>
                                    <copy
                                        file="${project.build.directory}/${project.build.finalName}.${project.packaging}"
                                        overwrite="true" todir="${install.dir}" />
                                </tasks>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
Below is the project workspace screen grab

The META-INF folder is the home for the MANIFEST. MF file. This file contains meta data about the contents of the JAR. For example, there is an entry called Main-Class that specifies the name of the Java class with the static main() for executable JAR files.
Basically it has to be in your classpath(under /META-INF/ ). You can manually enable it in eclipse by configuring properties. If your project is maven based, then it should be automatically picked from /src/main/resources/META-INF/ folder (provided entities are under the same hood).
The correct way is to add files to src/main/application instead of src/main/resources.
You can also specify a different earSourceDirectory configuration.
I suggest you use the Maven resources plugin at the prepare-package phase to copy the file to the ${build.directory}/${project.artifactId}-${project.version}/META-INF folder which is the folder where the final EAR is zipped from. The phase prepare-package is just before the EAR is zipped up.
The simplest way, at least if it is not an EAR (did not try that), is to simply have a META-INF directory with the wanted files in ./src/main/resources. Of course that does not solve your problem is the file is generated to a different place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With