On Sun, Nov 2, 2014 at 10:41 AM, Hervé BOUTEMY <[email protected]> wrote: > Le dimanche 2 novembre 2014 09:51:14 Dennis Lundberg a écrit : >> Looking into this I'm a bit puzzled. Version 1.1-SNAPSHOT of >> maven-toolchains-plugin bind by default to the validate phase, but it >> doesn't run unless I specify an execution for it. If I have it >> specified in build/plugins with configuration but no execution it >> doesn't run. If I add the execution it runs. What am I missing? > I made the same experiment when writing the IT, with same expectations and > surprise :) > > IIUC, wrong expectations based on reporting plugins experience: this is the > way reports are automagically executed, but normal plugins are not the same > beasts
I think that I've figured out how this works now. The "defaultPhase" annotation on a mojo only serves as a default value for <phase> if the plugin is invoked via an execution, and no <phase> is configured for that plugin execution. I tried this on one of my projects, both with and without a <phase> in the execution and these are the results. Without <phase>: [INFO] ------------------------------------------------------------------------ [INFO] Building Dennis Lundberg Log File Parser Common 1.6-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ dennislundberg-logfileparser-common --- [INFO] Deleting G:\dennislundberg\dennislundberg-logfileparser\common\target [INFO] [INFO] --- maven-toolchains-plugin:1.1-SNAPSHOT:toolchain (default) @ dennislundberg-logfileparser-common --- [INFO] Required toolchain type:jdk [INFO] Toolchain (jdk) matched: JDK[C:/Program Files/Java/jdk1.5.0_22] [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ dennislundberg-logfileparser-common --- [INFO] Using 'ISO-8859-1' encoding to copy filtered resources. [INFO] Copying 2 resources [INFO] [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ dennislundberg-logfileparser-common --- [INFO] Toolchain in compiler-plugin: JDK[C:/Program Files/Java/jdk1.5.0_22] [INFO] Compiling 16 source files to G:\dennislundberg\dennislundberg-logfileparser\common\target\classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ dennislundberg-logfileparser-common --- [INFO] Using 'ISO-8859-1' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory G:\dennislundberg\dennislundberg-logfileparser\common\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ dennislundberg-logfileparser-common --- [INFO] Toolchain in compiler-plugin: JDK[C:/Program Files/Java/jdk1.5.0_22] [INFO] Compiling 3 source files to G:\dennislundberg\dennislundberg-logfileparser\common\target\test-classes [INFO] [INFO] --- maven-surefire-plugin:2.17:test (default-test) @ dennislundberg-logfileparser-common --- [INFO] Toolchain in surefire-plugin: JDK[C:/Program Files/Java/jdk1.5.0_22] ... With <phase>validate</phase>: [INFO] ------------------------------------------------------------------------ [INFO] Building Dennis Lundberg Log File Parser Common 1.6-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ dennislundberg-logfileparser-common --- [INFO] Deleting G:\dennislundberg\dennislundberg-logfileparser\common\target [INFO] [INFO] --- maven-toolchains-plugin:1.1-SNAPSHOT:toolchain (default) @ dennislundberg-logfileparser-common --- [INFO] Required toolchain type:jdk [INFO] Toolchain (jdk) matched: JDK[C:/Program Files/Java/jdk1.5.0_22] [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ dennislundberg-logfileparser-common --- [INFO] Using 'ISO-8859-1' encoding to copy filtered resources. [INFO] Copying 2 resources [INFO] [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ dennislundberg-logfileparser-common --- [INFO] Toolchain in compiler-plugin: JDK[C:/Program Files/Java/jdk1.5.0_22] [INFO] Compiling 16 source files to G:\dennislundberg\dennislundberg-logfileparser\common\target\classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ dennislundberg-logfileparser-common --- [INFO] Using 'ISO-8859-1' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory G:\dennislundberg\dennislundberg-logfileparser\common\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ dennislundberg-logfileparser-common --- [INFO] Toolchain in compiler-plugin: JDK[C:/Program Files/Java/jdk1.5.0_22] [INFO] Compiling 3 source files to G:\dennislundberg\dennislundberg-logfileparser\common\target\test-classes [INFO] [INFO] --- maven-surefire-plugin:2.17:test (default-test) @ dennislundberg-logfileparser-common --- [INFO] Toolchain in surefire-plugin: JDK[C:/Program Files/Java/jdk1.5.0_22] ... With <phase>compile</phase>: [INFO] ------------------------------------------------------------------------ [INFO] Building Dennis Lundberg Log File Parser Common 1.6-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ dennislundberg-logfileparser-common --- [INFO] Deleting G:\dennislundberg\dennislundberg-logfileparser\common\target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ dennislundberg-logfileparser-common --- [INFO] Using 'ISO-8859-1' encoding to copy filtered resources. [INFO] Copying 2 resources [INFO] [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ dennislundberg-logfileparser-common --- [INFO] Compiling 16 source files to G:\dennislundberg\dennislundberg-logfileparser\common\target\classes [INFO] [INFO] --- maven-toolchains-plugin:1.1-SNAPSHOT:toolchain (default) @ dennislundberg-logfileparser-common --- [INFO] Required toolchain type:jdk [INFO] Toolchain (jdk) matched: JDK[C:/Program Files/Java/jdk1.5.0_22] [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ dennislundberg-logfileparser-common --- [INFO] Using 'ISO-8859-1' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory G:\dennislundberg\dennislundberg-logfileparser\common\src\test\resources [INFO] [INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ dennislundberg-logfileparser-common --- [INFO] Toolchain in compiler-plugin: JDK[C:/Program Files/Java/jdk1.5.0_22] [INFO] Compiling 3 source files to G:\dennislundberg\dennislundberg-logfileparser\common\target\test-classes [INFO] [INFO] --- maven-surefire-plugin:2.17:test (default-test) @ dennislundberg-logfileparser-common --- [INFO] Toolchain in surefire-plugin: JDK[C:/Program Files/Java/jdk1.5.0_22] ... As you can see from the output there is no difference between the no-phase build and the phase=validate build. They are equivalent. The phase=compile build on the other hand shows that the toolchains plugin runs after the compiler plugin, because we have specified a non-default phase for it. The "defaultPhase" annotation on a mojo says nothing about whether the plugin will actually be executed or not. That is something that comes from the file maven\maven-core\src\main\resources\META-INF\plexus\default-bindings.xml in maven core. This is where the default executions are specified, and this is where the automagic happens :-) A few days ago there was a discussion about whether to bind the FailSafe plugin to the verify phase. If we were to do that, then we would do it in this file. > > Regards, > > Hervé > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > -- Dennis Lundberg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
