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

  • Home
  • SEARCH
  • 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 7709781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:56:54+00:00 2026-06-01T00:56:54+00:00

I wrote and tested a custom enforcer rule to do distribution specific builds on

  • 0

I wrote and tested a custom enforcer rule to do distribution specific builds on various Linux distributions. It tests well with the mvn enforcer:enforce command, with the provided pom.xml build snippet.

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <version>1.0-beta-1</version>
    <dependencies>
      <dependency>
        <groupId>org.example</groupId>
        <artifactId>maven-enforcer-rule-redhat6x</artifactId>
        <version>1.0</version>
      </dependency>
    </dependencies>
    <configuration>
      <rules>
        <redhat6x implementation="org.example.enforcer.Redhat6x">
          <compatible>true</compatible>
        </redhat6x>
      </rules>
    </configuration>
    <executions>
      <execution>
        <id>enforce</id>
      </execution>
    </executions>
    <goals>
      <goal>enforce</goal>
    </goals>
  </plugin>
</plugins>

After racking my brain and doing a lot of experimental testing, I cannot seem to find how to use this custom enforcer rule as a profile activation selector.

  <profiles>
    <profile>
      <id>RedHat6x</id>
      <activation>
      <!-- Something goes here, but what?  This doesn't work -->
            <redhat6x implementation="com.cisco.tesdw.enforcer.Redhat6x">
              <compatible>true</compatible>
            </redhat6x>
      </activation>
    </profile>
  </profiles>

There are some hints that profile activation uses maven-enforcer-rules as detailed in the Introduction to Profiles page under the section “How can I tell which profiles are in effect during a build” section. Namely, every profile activation which has multiple string values (os name, etc) is referred to the corresponding maven enforcer rule. However, it seems that direct inclusion of a custom profile activator isn’t obvious in the pom.xml, and adding such would likely require a pom version update.

Maven3 is also extensible in ways that are very flexible, is it possible to hook inclusion of my enforcer rule by the maven extensions mechanism? There is documentation on how to include custom lifecycle participants; but, I fear that profile activation may have already occurred by the time the build starts. Documentation is sparse, but the javadoc indicates that AbstractMavenLifecycleParticipant.afterProjectsRead(MavenSession session) is called “after all MavenProject instances have been created”. This leaves some doubt in my mind whether it is called is before of after profile activation. I suspect after, or how would one get a properly configured MavenProject?

Could someone tell me if profile activation customization is even remotely possible?

  • 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-01T00:56:56+00:00Added an answer on June 1, 2026 at 12:56 am

    You just need to move plugin configuration under profile:

    <profiles>
        <profile>
          <id>RedHat6x</id>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-enforcer-plugin</artifactId>
              <version>1.0-beta-1</version>
              <dependencies>
                <dependency>
                  <groupId>org.example</groupId>
                  <artifactId>maven-enforcer-rule-redhat6x</artifactId>
                  <version>1.0</version>
                </dependency>
              </dependencies>
              <configuration>
                <rules>
                  <redhat6x implementation="org.example.enforcer.Redhat6x">
                    <compatible>true</compatible>
                  </redhat6x>
                </rules>
              </configuration>
              <executions>
                <execution>
                  <id>redhat-enforce</id>
                </execution>
              </executions>
              <goals>
                <goal>enforce</goal>
              </goals>
            </plugin>
          </plugins>
        </profile>
    </profiles>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SOLVED: I wrote and tested a PHP script on the local server. (Nothing fancy,
I wrote a javascript function (already tested it and it works) on a file
I wrote a simple file upload application using ASP.NET MVC. I tested it successfully
I wrote a demo HelloWorld Rails app and tested it with WEBrick (it doesn't
I wrote and tested some code in a Windows XP (Qt 4.7.2) using Visual
I wrote a Google Maps API wrapper in JS, did some local tests with
I wrote a function that builds an XML string based on the data saved
I have Fedora (latest) installed as well as mingw32 and gtk packages. I wrote
I've installed firebug and I wrote all these log statements. I've tested my app
I wrote a few cool programs and tested them with Windows 7 and OS

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.