Skip to content

Commit 77dc697

Browse files
laurentschoelensmattrpav
authored andcommitted
[#502] fix for m2e runOnConfiguration will only setupDirectories and no more execute actual XJC
1 parent db7de56 commit 77dc697

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/RawXJC2Mojo.java

+28-20
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
import org.jvnet.jaxb.maven.util.LocaleUtils;
7676
import org.jvnet.jaxb.maven.util.CollectionUtils.Function;
7777
import org.sonatype.plexus.build.incremental.BuildContext;
78+
import org.sonatype.plexus.build.incremental.ThreadBuildContext;
7879
import org.xml.sax.EntityResolver;
7980
import org.xml.sax.InputSource;
8081
import org.xml.sax.SAXException;
@@ -465,30 +466,37 @@ protected void doExecute() throws MojoExecutionException {
465466
if (getGrammars().isEmpty()) {
466467
getLog().warn("No schemas to compile. Skipping XJC execution. ");
467468
} else {
468-
469+
final boolean configurationPhase = this.getBuildContext() instanceof ThreadBuildContext
470+
&& ThreadBuildContext.getContext().getClass().getName().endsWith("EclipseEmptyBuildContext");
469471
final O options = getOptionsFactory().createOptions(optionsConfiguration);
470472

471-
if (getForceRegenerate()) {
472-
getLog().warn("You are using forceRegenerate=true in your configuration.\n"
473-
+ "This configuration setting is deprecated and not recommended "
474-
+ "as it causes problems with incremental builds in IDEs.\n"
475-
+ "Please refer to the following link for more information:\n"
476-
+ "https://github.com/highsource/jaxb-tools/wiki/Do-Not-Use-forceRegenerate\n"
477-
+ "Consider removing this setting from your plugin configuration.\n");
478-
getLog().info("The [forceRegenerate] switch is turned on, XJC will be executed.");
479-
} else {
480-
final boolean isUpToDate = isUpToDate();
481-
if (!isUpToDate) {
482-
getLog().info("Sources are not up-to-date, XJC (version " + getVersion().getRaw() + ") will be executed.");
483-
} else {
484-
getLog().info("Sources are up-to-date, XJC (version " + getVersion().getRaw() + ") will be skipped.");
485-
return;
486-
}
487-
}
473+
if (!configurationPhase) {
474+
if (getForceRegenerate()) {
475+
getLog().warn("You are using forceRegenerate=true in your configuration.\n"
476+
+ "This configuration setting is deprecated and not recommended "
477+
+ "as it causes problems with incremental builds in IDEs.\n"
478+
+ "Please refer to the following link for more information:\n"
479+
+ "https://github.com/highsource/jaxb-tools/wiki/Do-Not-Use-forceRegenerate\n"
480+
+ "Consider removing this setting from your plugin configuration.\n");
481+
getLog().info("The [forceRegenerate] switch is turned on, XJC will be executed.");
482+
} else {
483+
final boolean isUpToDate = isUpToDate();
484+
if (!isUpToDate) {
485+
getLog().info("Sources are not up-to-date, XJC (version " + getVersion().getRaw() + ") will be executed.");
486+
} else {
487+
getLog().info("Sources are up-to-date, XJC (version " + getVersion().getRaw() + ") will be skipped.");
488+
return;
489+
}
490+
}
491+
}
488492

489493
setupDirectories();
490-
doExecute(options);
491-
addIfExistsToEpisodeSchemaBindings();
494+
if (!configurationPhase) {
495+
doExecute(options);
496+
addIfExistsToEpisodeSchemaBindings();
497+
} else {
498+
getLog().info("Sources will not be generated since running in EclipseEmptyBuildContext, XJC will be skipped.");
499+
}
492500
final BuildContext buildContext = getBuildContext();
493501
getLog().debug(MessageFormat.format("Refreshing the generated directory [{0}].",
494502
getGenerateDirectory().getAbsolutePath()));

0 commit comments

Comments
 (0)