Why didn't you use the xml snippet I sent you? It is correct while the one you've created is wrong.
/Anders On Thu, Oct 25, 2012 at 4:56 PM, Arnaud bourree <[email protected]> wrote: > <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/xsd/maven-4.0.0.xsd"> > <modelVersion>4.0.0</modelVersion> > <!-- Parent must be acme-parent. --> > <parent> > <groupId>com.acme.rules</groupId> > <artifactId>acme-parent</artifactId> > <version>1.0</version> > </parent> > <groupId>tmp.cub.rule</groupId> > <artifactId>inherit-usage</artifactId> > <version>1.0</version> > <packaging>pom</packaging> > <build> > <pluginManagement> > <plugins> > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-enforcer-plugin</artifactId> > <version>${enforcer-api.version}</version> > <dependencies> > <dependency> > <groupId>com.acme.rules</groupId> > <artifactId>cub-enforcer-rules</artifactId> > <version>${project.version}</version> > </dependency> > </dependencies> > <executions> > <execution> > <configuration> > <rules> > <AcmeParentInheritRule > implementation="com.acme.rules.AcmeParentInheritRule"/> > </rules> > </configuration> > </execution> > </executions> > </plugin> > </plugins> > </pluginManagement> > <plugins> > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-enforcer-plugin</artifactId> > <executions> > <execution> > <id>acme-parent</id> > <goals> > <goal>enforce</goal> > </goals> > <configuration> > <rules> > <AcmeParentInheritRule > implementation="com.acme.rules.AcmeParentInheritRule"/> > </rules> > </configuration> > </execution> > </executions> > </plugin> > </plugins> > </build> > </project> > > 2012/10/25 Anders Hammar <[email protected]>: >> I can't say for sure as you don't provide a link to your pom, but I'm >> fairly sure you've configured it wrong. It should work. >> >> /Anders >> >> On Thu, Oct 25, 2012 at 2:13 PM, Arnaud bourree >> <[email protected]> wrote: >>> I try without sucess: >>> [INFO] Scanning for projects... >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] Building Unnamed - tmp.acme.rule:inherit-usage:pom:1.0 >>> [INFO] task-segment: [enforcer:enforce] >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] >>> ------------------------------------------------------------------------ >>> [ERROR] BUILD ERROR >>> [INFO] >>> ------------------------------------------------------------------------ >>> [INFO] One or more required plugin parameters are invalid/missing for >>> 'enforcer:enforce' >>> >>> [0] Inside the definition for plugin 'maven-enforcer-plugin' specify >>> the following: >>> >>> <configuration> >>> ... >>> <rules>VALUE</rules> >>> </configuration>. >>> >>> >>> Note that I run it after mvn clear >>> >>> Arnaud. >>> >>> 2012/10/25 Anders Hammar <[email protected]>: >>>> In your configuration, the rule configuration is on execution level >>>> meaning that it will only be used for the lifecycle execution (mvn >>>> package e.g.) and not when execution the plugin for command line (mvn >>>> enforcer:enforce). >>>> >>>> There's been some noise around using the enforcer plugin from >>>> command-line lately (is it you?). Personally I don't really get it, >>>> but that's just me. >>>> >>>> If you want to be able to run mvn enforcer:enforce you need to move >>>> the configuration to plugin level and also put it in the >>>> pluginManagement section. Something like this: >>>> >>>> <build> >>>> <pluginManagement> >>>> <plugins> >>>> <plugin> >>>> <groupId>org.apache.maven.plugins</groupId> >>>> <artifactId>maven-enforcer-plugin</artifactId> >>>> <version>1.1.1</version> >>>> <configuration> >>>> <rules> >>>> <AcmeParentInheritRule >>>> implementation="com.acme.AcmeParentInheritRule" /> >>>> </rules> >>>> </configuration> >>>> <dependencies> >>>> <dependency> >>>> <groupId>com.acme</groupId> >>>> <artifactId>acme-enforcer-rules</artifactId> >>>> <version>1.0</version> >>>> </dependency> >>>> </dependencies> >>>> </plugin> >>>> </plugins> >>>> </pluginManagement> >>>> <plugins> >>>> <plugin> >>>> <groupId>org.apache.maven.plugins</groupId> >>>> <artifactId>maven-enforcer-plugin</artifactId> >>>> <executions> >>>> <execution> >>>> <id>enforcer-check</id> >>>> <goals> >>>> <goal>enforce</goal> >>>> </goals> >>>> </execution> >>>> </executions> >>>> </plugin> >>>> </plugins> >>>> </build> >>>> >>>> This is the simplest way of doing this, btu there are drawbacks. One >>>> is that all execution bindings will have the same rule set. In your >>>> case probably not an issue. If it is an issue there are ways around >>>> this by using the magic id ("default-cli") for the command line >>>> execution. I have never used that magic id though in a real world use >>>> case. >>>> >>>> /Anders >>>> >>>> On Thu, Oct 25, 2012 at 10:01 AM, Arnaud bourree >>>> <[email protected]> wrote: >>>>> On my side, I put configuration in <plugins> section and not in >>>>> <pluginManagment> one. >>>>> <build> >>>>> <plugins> >>>>> <plugin> >>>>> <groupId>org.apache.maven.plugins</groupId> >>>>> <artifactId>maven-enforcer-plugin</artifactId> >>>>> <version>1.1.1</version> >>>>> <dependencies> >>>>> <dependency> >>>>> <groupId>com.acme</groupId> >>>>> <artifactId>acme-enforcer-rules</artifactId> >>>>> <version>1.0</version> >>>>> </dependency> >>>>> </dependencies> >>>>> <executions> >>>>> <execution> >>>>> <configuration> >>>>> <rules> >>>>> <AcmeParentInheritRule >>>>> implementation="com.acme.AcmeParentInheritRule"/> >>>>> </rules> >>>>> </configuration> >>>>> <goals> >>>>> <goal>enforce</goal> >>>>> </goals> >>>>> </execution> >>>>> </executions> >>>>> </plugin> >>>>> </plugins> >>>>> </build> >>>>> >>>>> And I note that "mvn enforcer:enforce" doesn't work without "package" >>>>> So I run "mvn package enforcer:enforce" >>>>> But in fact if you run "mvn package" maven will run enforcer rules >>>>> >>>>> Arnaud >>>>> >>>>> 2012/10/25 Anders Hammar <[email protected]>: >>>>>> You probably have the configuration in the wrong place. Is it on >>>>>> plugin level or execution level? It has to be on plugin level if >>>>>> you're to run "mvn enforcer:enforce". Also, it should be in the >>>>>> pluginManagement section. >>>>>> >>>>>> /Anders >>>>>> >>>>>> On Thu, Oct 25, 2012 at 7:27 AM, Wang, Simon <[email protected]> >>>>>> wrote: >>>>>>> I specified rule in pom.xml, after run "mvn enforcer:enforce", still >>>>>>> complain no rules set. >>>>>>> Really don't know what happened. >>>>>>> >>>>>>> Regards >>>>>>> Simon >>>>>>> -----Original Message----- >>>>>>> From: Arnaud bourree [mailto:[email protected]] >>>>>>> Sent: 2012年10月24日 22:18 >>>>>>> To: Maven Users List >>>>>>> Subject: Re: Specify enforcer:enforce rules from command line >>>>>>> >>>>>>> I create issue MENFORCER-142 >>>>>>> >>>>>>> I found a partial work-around: running mvn enforcer:enforce fail if >>>>>>> there is no rules set :-/ >>>>>>> >>>>>>> But that not enough for me. >>>>>>> >>>>>>> Regards, >>>>>>> >>>>>>> Arnaud. >>>>>>> >>>>>>> >>>>>>> 2012/10/23 Anders Hammar <[email protected]>: >>>>>>>> Don't think it's possible. The enforcer plugin is meant to be bound to >>>>>>>> the build lifecycle so it should be configured in the pom. But I guess >>>>>>>> an enhancement ticket with a patch could change that? :-) >>>>>>>> >>>>>>>> /Anders >>>>>>>> >>>>>>>> On Tue, Oct 23, 2012 at 5:50 PM, Arnaud bourree >>>>>>>> <[email protected]> wrote: >>>>>>>>> Hello, >>>>>>>>> >>>>>>>>> How could we specify enforcer:enforce rules from command line? >>>>>>>>> >>>>>>>>> I want to run command line like following without updating any >>>>>>>>> pom.xml: >>>>>>>>> mvn enforcer:enforce -Drules=com.acme.UseAcmeParentPom >>>>>>>>> >>>>>>>>> The goal of this enforcer:enforce rule is to check that Acme's >>>>>>>>> developers write pom.xml which inherit from acme's parent pom.xml And >>>>>>>>> because they may not inherit from acme's parent pom.xml, I cannot >>>>>>>>> specify enforcer rule in. >>>>>>>>> >>>>>>>>> Regards, >>>>>>>>> >>>>>>>>> Arnaud. >>>>>>>>> >>>>>>>>> --------------------------------------------------------------------- >>>>>>>>> To unsubscribe, e-mail: [email protected] >>>>>>>>> For additional commands, e-mail: [email protected] >>>>>>>>> >>>>>>>> >>>>>>>> --------------------------------------------------------------------- >>>>>>>> To unsubscribe, e-mail: [email protected] >>>>>>>> For additional commands, e-mail: [email protected] >>>>>>>> >>>>>>> >>>>>>> --------------------------------------------------------------------- >>>>>>> To unsubscribe, e-mail: [email protected] >>>>>>> For additional commands, e-mail: [email protected] >>>>>>> >>>>>> >>>>>> --------------------------------------------------------------------- >>>>>> To unsubscribe, e-mail: [email protected] >>>>>> For additional commands, e-mail: [email protected] >>>>>> >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: [email protected] >>>>> For additional commands, e-mail: [email protected] >>>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [email protected] >>>> For additional commands, e-mail: [email protected] >>>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [email protected] >>> For additional commands, e-mail: [email protected] >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
