0

If I define toolchain plugin in activated by default profile it's not working for some plugin such as maven-javadoc-plugin(for maven-compiler-plugin it is working) :

<profile>
    <id>jdk-toolchain</id>
    <activation>
        <activeByDefault>true</activeByDefault>
    </activation>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-toolchains-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>toolchain</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <toolchains>
                        <jdk>
                            <version>${project.javaVersion}</version>
                            <vendor>sun</vendor>
                        </jdk>
                    </toolchains>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

In other case it work perfect for all plugin:

<build>
    <plugins>
...
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-toolchains-plugin</artifactId>
                    <version>1.1</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>toolchain</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <toolchains>
                            <jdk>
                                <version>${project.javaVersion}</version>
                                <vendor>sun</vendor>
                            </jdk>
                        </toolchains>
                    </configuration>
                </plugin>
...
    </plugins>
</build>

Why is this happening?

cb4
  • 6,689
  • 7
  • 45
  • 57
burtsevyg
  • 3,851
  • 2
  • 29
  • 44
  • 1
    Why would you like to put the toolchain into a profile? Does not make really sense ? – khmarbaise Mar 23 '16 at 08:52
  • It's not metter but toolchain in profile does not work for some plugin. You could check it. – burtsevyg Mar 23 '16 at 09:36
  • 2
    Ok..first if there is an isse create a jira issue for that...But why are you using toolchain in a profile does not make sense? – khmarbaise Mar 23 '16 at 10:42
  • I only want to know it's error in my pom because I don't understand something in profiles or known issue in maven. – burtsevyg Mar 23 '16 at 11:48
  • I agree with you using toolchain in profile does not make sense – burtsevyg Mar 23 '16 at 11:53
  • 2
    What do you mean by `..default it's not working for some plugin` ...Can you create a full working example and may be put on github ... – khmarbaise Mar 23 '16 at 11:59
  • Sorry for my bad English I mean ...in activated by default profile... – burtsevyg Mar 23 '16 at 12:17
  • It might make sense if e.g. a project must work on jdk6 but most of the development can be done in 8/people not having 6. Then only for "final builds" a toolchain with jdk6 could be used. However it seems at least jdk based profile activations activate based on jdk used to run maven and not toolchain (I'm having this issue and this is the first result google gave so decided to comment). – Bjarne Boström Nov 25 '16 at 11:53

1 Answers1

0

you have to bind the execution of your plugin into validate phase:

<executions>
    <execution>
        <phase>validate</phase>
        <goals>
            <goal>toolchain</goal>
            </goals>
    </execution>
</executions>