From 336bcf2ace7f2d89145f87a558c6070a43830928 Mon Sep 17 00:00:00 2001 From: Alekseeva Yana Date: Tue, 5 Dec 2023 18:50:42 +0300 Subject: [PATCH 1/2] fix(#2668): added todo + fix test --- .../java/org/eolang/maven/AssembleMojo.java | 59 +++++++++++++++++++ .../org/eolang/maven/AssembleMojoTest.java | 1 - .../test/java/org/eolang/maven/FakeMaven.java | 7 --- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java index 6c89add7cc..29cbfc5965 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java @@ -27,12 +27,14 @@ import java.io.File; import java.io.IOException; import java.nio.file.Path; +import java.util.Set; import java.util.function.BiConsumer; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.cactoos.set.SetOf; import org.eolang.maven.objectionary.Objectionaries; import org.eolang.maven.objectionary.ObjsDefault; @@ -40,6 +42,17 @@ * Pull all necessary EO XML files from Objectionary and parse them all. * * @since 0.1 + * @todo #2406:90min Make up with idea how to get rid of duplicate parameters between mojos. + * There's a situation where AssembleMojo owns, creates and executes other mojos, + * like {@link ParseMojo} or {@link OptimizeMojo}. When we configure our compiler via pom.xml maven + * tries to set parameters directly to the calling mojo. That's why we must to have all parameters + * from child mojos in AssembleMojo or {@link SafeMojo} (in order they won't be skipped and lost). + * That causes duplication of parameters between "parent" mojo and "child" mojos. + * Also it obliges the developer to remember that if he adds new parameter to some child mojo, + * this parameter must be present in parent mojo as well. + * We didn't find a way how we can resolve such duplication at the moment. + * So we need to either accept this as impossible to solve or resolve somehow. + * Anyway don't forget to remove the puzzle when the decision about the puzzle is made. */ @Mojo( name = "assemble", @@ -65,6 +78,24 @@ public final class AssembleMojo extends SafeMojo { ) private File outputDir; + /** + * List of inclusion GLOB filters for finding class files. + * @since 0.15 + * @checkstyle MemberNameCheck (7 lines) + * @checkstyle ConstantUsageCheck (5 lines) + */ + @Parameter + private final Set includeBinaries = new SetOf<>("**"); + + /** + * List of exclusion GLOB filters for finding class files. + * @since 0.15 + * @checkstyle MemberNameCheck (7 lines) + * @checkstyle ConstantUsageCheck (5 lines) + */ + @Parameter + private final Set excludeBinaries = new SetOf<>(); + /** * Objectionaries. * @checkstyle MemberNameCheck (6 lines) @@ -89,6 +120,24 @@ public final class AssembleMojo extends SafeMojo { @Parameter(property = "eo.overWrite", required = true, defaultValue = "false") private boolean overWrite; + /** + * Track optimization steps into intermediate XML files? + * + * @checkstyle MemberNameCheck (7 lines) + * @since 0.24.0 + */ + @SuppressWarnings("PMD.LongVariable") + @Parameter(property = "eo.trackOptimizationSteps", required = true, defaultValue = "false") + private boolean trackOptimizationSteps; + + /** + * The Git tag to pull objects from, in objectionary. + * @since 0.21.0 + */ + @SuppressWarnings("PMD.ImmutableField") + @Parameter(property = "eo.tag", required = true, defaultValue = "master") + private String tag = "master"; + /** * Skip artifact with the version 0.0.0. * @checkstyle MemberNameCheck (7 lines) @@ -105,6 +154,16 @@ public final class AssembleMojo extends SafeMojo { @Parameter(property = "eo.discoverSelf", required = true, defaultValue = "false") private boolean discoverSelf; + /** + * Fail resolution process on conflicting dependencies. + * + * @checkstyle MemberNameCheck (7 lines) + * @since 1.0 + */ + @Parameter(property = "eo.ignoreVersionConflicts", required = true, defaultValue = "false") + @SuppressWarnings("PMD.LongVariable") + private boolean ignoreVersionConflicts; + /** * Whether we should fail on error. * @checkstyle MemberNameCheck (7 lines) diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/AssembleMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/AssembleMojoTest.java index db3330bce3..be34d72d36 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/AssembleMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/AssembleMojoTest.java @@ -262,7 +262,6 @@ void assemblesSuccessfullyInOfflineMode(final Logs out, @TempDir final Path temp } @Test - @Disabled void configuresChildParameters(@TempDir final Path temp) throws IOException { final Map res = new FakeMaven(temp) .withHelloWorld() diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java b/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java index 261c5ff084..6a4ccf8350 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java @@ -70,13 +70,6 @@ * their behaviour and results. * NOT thread-safe. * @since 0.28.12 - * @todo #2406:30min Fix {@link FakeMaven#allowedParams(Class)} - * This function configures parameters of executed Mojo in {@link FakeMaven#execute(Class)} - * and parameters those Mojos which are inside this executed Mojo. - * If executed Mojo doesn't have parameters that are inside other Mojos, - * other Mojos parameters will not be configured. - * We need to make sure that custom parameters can be configured too. - * We need to enable the test {@link AssembleMojoTest#configuresChildParameters(Path)}. */ @SuppressWarnings({ "PMD.TooManyMethods", From ef024e28dab78115c8b5b78056cef8cf171545be Mon Sep 17 00:00:00 2001 From: Alekseeva Yana Date: Wed, 6 Dec 2023 15:13:01 +0300 Subject: [PATCH 2/2] fix(#2668): deleted parameter 'hash' from SafeMojo --- .../src/main/java/org/eolang/maven/SafeMojo.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java index c8c59b1988..4f7291a671 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java @@ -236,15 +236,6 @@ abstract class SafeMojo extends AbstractMojo { new Sticky<>(() -> Catalogs.INSTANCE.make(this.transpiled.toPath(), this.transpiledFormat)) ); - /** - * The Git hash to pull objects from, in objectionary. - * If not set, will be computed from {@code tag} field. - * - * @since 0.29.6 - */ - @SuppressWarnings({"PMD.ImmutableField", "PMD.UnusedPrivateField"}) - private CommitHash hash; - /** * Cached tojos. * @checkstyle VisibilityModifierCheck (5 lines)