0

I'm currently migrating some Java project to Maven structure and I ran into a problem. Old EAR project contains jboss-deployment-structure.xml, so I've moved it to a Maven project under <EAR-ROOT>/src/main/application/META-INF. When I build a project, descriptor is placed correctly in EAR file, but since it's Maven project, I'm thinking about generating jboss-deployment-structure.xml using Maven, since it contains many references to jar libraries. Now when I e.g. change some Java library version in pom.xml, I also have to manually change it in jboss-deployment-structure.xml.

Part of my jboss-deployment-structure.xml:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <!-- Make sub deployments isolated by default, so they cannot see each others 
        classes without a Class-Path entry -->
    <ear-subdeployments-isolated>true</ear-subdeployments-isolated>
    <deployment>
        <resources>
            <resource-root path="lib/apache/commons-lang3-3.3.2.jar" />
            <resource-root path="lib/joda/joda-time-2.0.jar" />
        </resources>
    </deployment>
</jboss-deployment-structure>

So my question - Is it possible to generate jboss-deployment-structure.xml using Maven? I've already searched for some appropriate plugin, but I couldn't find any. Can descriptor be generated in any other way?

Thanks in advance.

1 Answer 1

1

One way you could automate the generation of the jboss-deployment-structure.xml is by using the Maven resource filtering feature, which allows you to replace placeholders in your resource files with their respective values from the Maven properties during the build process.

You would first need to include placeholders for the versions of your libraries in the jboss-deployment-structure.xml, like so:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <!-- Make sub deployments isolated by default, so they cannot see each others 
        classes without a Class-Path entry -->
    <ear-subdeployments-isolated>true</ear-subdeployments-isolated>
    <deployment>
        <resources>
            <resource-root path="lib/apache/commons-lang3-${commons.lang.version}.jar" />
            <resource-root path="lib/joda/joda-time-${joda.time.version}.jar" />
        </resources>
    </deployment>
</jboss-deployment-structure>

Next, you would define these placeholders in your pom.xml:

<properties>
    <commons.lang.version>3.3.2</commons.lang.version>
    <joda.time.version>2.0</joda.time.version>
</properties>

Finally, you would need to configure your project to use Maven resource filtering. You can do this by adding a resources element to your build configuration in your pom.xml:

<build>
    <resources>
        <resource>
            <directory>src/main/application/META-INF</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    ...
</build>

This setup will replace the placeholders in your jboss-deployment-structure.xml with the respective values from the Maven properties when you build your project.

Remember to update the version numbers in the properties section of your pom.xml file whenever you change the version of a library, and the jboss-deployment-structure.xml will be updated automatically during the build process.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.