Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8712243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:04:13+00:00 2026-06-13T05:04:13+00:00

I have a multi-module build which contains modules which can target either Java 5

  • 0

I have a multi-module build which contains modules which can target either Java 5 or Java 6. I want to allow modules to opt-in to Java 6, and leaving the default to 5.

To set Java 5 as a target I need to configure the following:

  • maven-compiler-plugin: source and target set to 1.5
  • maven-bundle-plugin: configure the Bundle-RuntimeExecutionEnvironment to J2SE-1.5

To set Java 6 as a target I need to configure the following:

  • maven-compiler-plugin: source and target set to 1.6
  • maven-bundle-plugin: configure the Bundle-RuntimeExecutionEnvironment to JavaSE-1.6

I considered having two properties: java.compiler.source and osgi.bree which can be defined by each module, but this leaves place for error.

How can I override the configuration of these two plugins per module with a single switch?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:04:14+00:00Added an answer on June 13, 2026 at 5:04 am

    How about allowing child modules to set a my.java.version property (or whatever you want it named) and embedding a Groovy script that sets version properties for the compiler and bundle plugins? Something like this in the parent pom:

    <project ...>
        ...
        <properties>
            <my.java.version>1.5</my.java.version>     <!-- default Java version -->
        </properties>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.groovy.maven</groupId>
                    <artifactId>gmaven-plugin</artifactId>
                    <version>1.0</version>
                    <executions>
                        <execution>
                            <!-- set up properties in an early lifecycle phase -->
                            <phase>initialize</phase>
                            <goals>
                                <goal>execute</goal>
                            </goals>
                            <configuration>
                                <!-- this can be as simple or complex as you need it to be -->
                                <source>
                                    if (project.properties['my.java.version'] == '1.6') {
                                        project.properties['my.compiler.version'] = '1.6'
                                        project.properties['my.execution.environment.version'] = 'JavaSE-1.6'
                                    }
                                    else {
                                        project.properties['my.compiler.version'] = '1.5'
                                        project.properties['my.execution.environment.version'] = 'J2SE-1.5'
                                    }
                                </source>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
            <!-- now use the properties from above in the plugin configurations -->
            <!-- assume that both of these plugins will execute in a phase later than 'initialize' -->
            <pluginManagement>
                <plugins>
                    <plugin>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <source>${my.compiler.version}</source>
                            <target>${my.compiler.version}</target>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>maven-bundle-plugin</artifactId>
                        <configuration>
                            <!-- sorry if this part isn't correct; never used this plugin before -->
                            <instructions>
                                <Bundle-RuntimeExecutionEnvironment>${my.execution.environment.version}</Bundle-RuntimeExecutionEnvironment>
                            </instructions>
                        </configuration>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
    </project>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java multi-module Maven project that I want to build an MVN
I have a project in which the maven-enforcer rule fails with a multi-module build
I have a multi-module (maven) spring build. All the modules publish some beans, and
I have a maven multi-module pom which builds a war. I want to declare
I have a big Maven multi-module build set up in my Jenkins. It is
I have some multi-module project. Some modules are packaged as wars and some as
I have a multi module web project. Four modules of the project are packaged
I have a multi-module project. I thought I can compile only a single module
Basically, I have a multi-module project consisting of 5 different modules. One of the
I have a multi-module maven project made up of three sub-modules: web , service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.