Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameters setting in FakeMaven does not work on execution AssembleMojo #2406

Closed
maxonfjvipon opened this issue Aug 17, 2023 · 5 comments
Closed
Assignees
Labels
Milestone

Comments

@maxonfjvipon
Copy link
Member

I'm trying to test how AssembleMojo works with versions, my first attempt was:

@Test
void assemblesTogetherWithVersions(@TempDir final Path temp) throws Exception {
    final Map<String, CommitHash> hashes = new CommitHashesMap.Fake();
    final CommitHash master = hashes.get("master");
    final CommitHash five = hashes.get("0.28.5");
    final Map<String, Path> result = new FakeMaven(temp)
        .withVersionedHelloWorld()
        .with("withVersions", true)
        .with(
            "objectionaries",
            new ObjsDefault(
                new MapEntry<>(master, new OyRemote(master)),
                new MapEntry<>(five, new OyRemote(five)),
            )
        )
        .execute(AssembleMojo.class)
        .result();
    MatcherAssert.assertThat(
        result.get("target/classes").toAbsolutePath(),
        new ContainsFile("**/eo-runtime-0.28.5.jar")
    );
}

On resolve step I got an error:

15:09:04 [ERROR] org.eolang.maven.ResolveMojo: 1 conflicting dependencies are found: {org.eolang:eo-runtime:jar:=[0.28.5, 0.29.5]}

Then I tried to set ignoreVersionConflicts flag to true, now my code looks like this:

@Test
void assemblesTogetherWithVersions(@TempDir final Path temp) throws Exception {
    final Map<String, CommitHash> hashes = new CommitHashesMap.Fake();
    final CommitHash master = hashes.get("master");
    final CommitHash five = hashes.get("0.28.5");
    final Map<String, Path> result = new FakeMaven(temp)
        .withVersionedHelloWorld()
        .with("withVersions", true)
        .with("ignoreVersionConflicts", true) // <--- flag is set here
        .with(
            "objectionaries",
            new ObjsDefault(
                new MapEntry<>(master, new OyRemote(master)),
                new MapEntry<>(five, new OyRemote(five)),
            )
        )
        .execute(AssembleMojo.class)
        .result();
    MatcherAssert.assertThat(
        result.get("target/classes").toAbsolutePath(),
        new ContainsFile("**/eo-runtime-0.28.5.jar")
    );
}

I expect it works correctly and ignores conflicts but I still get the same error:

15:09:04 [ERROR] org.eolang.maven.ResolveMojo: 1 conflicting dependencies are found: {org.eolang:eo-runtime:jar:=[0.28.5, 0.29.5]}
@maxonfjvipon
Copy link
Member Author

maxonfjvipon commented Aug 17, 2023

I made a debugging of ResolveMojo and found out that even after I did with("ignoreVersionConflicts", true) this flag inside ResolveMojo is still false.
ignoreVersionConflicts flag exists only inside ResolveMojo, it does not exist in SafeMojo or AssembleMojo. So the problem is that we can't set "such" flags in certain mojos via FakeMaven when AssembleMojo is executed. "Such" means "that exist only inside certain mojo but not in AssembleMojo or SafeMojo". More examples of such flags:

  • "hsh" in ProbeMojo and PullMojo
  • "tag" in ProbeMojo and PullMojo

@Graur Graur added this to the Important milestone Aug 18, 2023
@Yanich96
Copy link
Contributor

@maxonfjvipon please assign me

Yanich96 added a commit to Yanich96/eo that referenced this issue Nov 30, 2023
Yanich96 added a commit to Yanich96/eo that referenced this issue Nov 30, 2023
Yanich96 added a commit to Yanich96/eo that referenced this issue Nov 30, 2023
Yanich96 added a commit to Yanich96/eo that referenced this issue Dec 1, 2023
@0pdd
Copy link

0pdd commented Dec 4, 2023

@maxonfjvipon the puzzle #2668 is still not solved.

@0pdd
Copy link

0pdd commented Dec 6, 2023

@maxonfjvipon the puzzle #2679 is still not solved; solved: #2668.

@maxonfjvipon
Copy link
Member Author

The main reason of such behaviour - mismatch of parameters between "parent" mojo (AssembleMojo) and "child" mojos (ResolveMojo is such case). When we put every field and parameter from child mojos to master mojo - everything works fine. #2679 - is the last relevant ticket related to the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants