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

Upgrade the generator to use the archetype version of the maven runtime #769

Merged
merged 4 commits into from
Jun 15, 2022

Conversation

laeubi
Copy link
Member

@laeubi laeubi commented Jun 13, 2022

Now as everything is decoupled, we can start upgrading the components...

@laeubi
Copy link
Member Author

laeubi commented Jun 13, 2022

This shows the removed support for a repository in the Archetype 3.x:

https://ci.eclipse.org/m2e/job/m2e/job/PR-769/1/testReport/junit/org.eclipse.m2e.tests/ProjectConfigurationManagerTest/testResolutionOfArchetypeFromRepository/

@mickaelistria @HannesWell as maven archetype do not support this anymore by direct invocation I would say we should remove the corresponding test as well?

@mickaelistria
Copy link
Contributor

/> as maven archetype do not support this anymore by direct invocation I would say we should remove the corresponding test as well?

Can't we migrate the test to verify the new behavior?

@laeubi
Copy link
Member Author

laeubi commented Jun 13, 2022

Can't we migrate the test to verify the new behavior?

Sure if you think its worth it one could simply assert the failure of course...

@mickaelistria
Copy link
Contributor

Sure if you think its worth it one could simply assert the failure of course...

I don't have a strong opinion as I'm presonally not using artifact and haven't seen many requests on those. You're the expert now, it's your call to decide whether removing tests is what's best or whether they still have value that will help sustainability, maintenance and innovation later.

@laeubi laeubi force-pushed the upgrade_to_archetype_3 branch from 7514520 to 6ff376b Compare June 13, 2022 16:28
@laeubi
Copy link
Member Author

laeubi commented Jun 13, 2022

You're the expert now, it's your call to decide whether removing tests is what's best or whether they still have value that will help sustainability, maintenance and innovation later.

I finally migrated the test to the newer archetype-aproach to define the repository in the settings.xml

@laeubi
Copy link
Member Author

laeubi commented Jun 13, 2022

@HannesWell I cherry-picket your adjustments to use latest archetype in the code as well and removed the deprecated repository code now, if that works we can merge and this should finally be done:

@laeubi
Copy link
Member Author

laeubi commented Jun 13, 2022

Sorry that was to early, this will only partly fix #249 as we use batch-mode so there is a slight adjustment required afterwards to allow the user use interactive mode...

@HannesWell
Copy link
Contributor

@HannesWell I cherry-picket your adjustments to use latest archetype in the code as well and removed the deprecated repository code now, if that works we can merge

In my last attempt there were test-failures and one open TODO associated to it. But maybe you can fix that. As written in #753 (comment) this is likely due to missing/faulty configuration.

@HannesWell
Copy link
Contributor

Btw. could you please also update the m2e-core-tests pointer with this PR after you have merged the adjusted tests.

@laeubi laeubi force-pushed the upgrade_to_archetype_3 branch from d4b0665 to 9fc7826 Compare June 14, 2022 04:36
@laeubi
Copy link
Member Author

laeubi commented Jun 14, 2022

Btw. could you please also update the m2e-core-tests pointer with this PR after you have merged the adjusted tests.

do you have something in mind here I should do immediately or before merging?

@laeubi
Copy link
Member Author

laeubi commented Jun 14, 2022

In my last attempt there were test-failures and one open TODO associated to it. But maybe you can fix that.

It becomes a bit more complex (and maybe that a reason a very old version was used before) as the archetype is actually a maven plugin and thus, if run from maven cli, has an own plugin classloading realm.

Now in m2e, we simply merge the two class pathes, what do not work well as both seem to use slightly different implementations and thus container injection fails later on... I'll try if we can replicate this behavior.

That said, it might even be beneficial that we do not upgrade the internal archetype at all as the generation of the archetype itself is now done without a problem by maven itself, thus as a user one wont notice that and we just use that for the parsing of the catalogues, where we might even be able to call the code directly.

@HannesWell
Copy link
Contributor

Sounds problematic.

As shortly outlined in #249 (comment) do you think it would be doable to just embed archetype-catalog and archetype-descriptor and drop archetype-common? We would then not need any of the other dependencies any more so the m2e.archetype bundle would be very small and maybe this also avoids the classpath issue you just described (but that's just a hope while having only very few knowledge).
I tested that locally and it looks like mainly org.apache.maven.archetype.ArchetypeManager and org.apache.maven.archetype.ArchetypeGenerationRequest has to be replaced then.
I can update #753 to show that.

@laeubi
Copy link
Member Author

laeubi commented Jun 14, 2022

If I can fix the container issue we can most probably remove everything that we do not reference as a type in m2e...

@laeubi
Copy link
Member Author

laeubi commented Jun 14, 2022

do you think it would be doable to just embed archetype-catalog and archetype-descriptor and drop archetype-common

I think we can't get rid of commons, but at least my approach to build a plugin realm that is connected to some classes failed :-
What would be required here, is that we write an abstraction layer over the maven impl, then create a maven component we inject into the plugin realm and lookup our facade.

Even though I have all that together from the maven side, I think I'll first start with a much simpler approach as we actually only need ArchetypeArtifactManager and ArchetypeDataSource from the container.

@laeubi laeubi force-pushed the upgrade_to_archetype_3 branch 3 times, most recently from b9be33d to 4b62a53 Compare June 14, 2022 16:01
@laeubi laeubi marked this pull request as ready for review June 14, 2022 16:09
@laeubi laeubi force-pushed the upgrade_to_archetype_3 branch from 4b62a53 to 3019c69 Compare June 15, 2022 03:23
@laeubi laeubi force-pushed the upgrade_to_archetype_3 branch from 3019c69 to 811d16a Compare June 15, 2022 03:41
@laeubi laeubi merged commit e33057c into eclipse-m2e:master Jun 15, 2022
@laeubi
Copy link
Member Author

laeubi commented Jun 15, 2022

@HannesWell this is now all green, I think we can reduce dependencies further (e.g. velocity and groovy should not be required anymore, even maybe more of the plexus stuff) but I'll leave this exercise to the interested reader :-)

@HannesWell
Copy link
Contributor

@HannesWell this is now all green, I think we can reduce dependencies further (e.g. velocity and groovy should not be required anymore, even maybe more of the plexus stuff) but I'll leave this exercise to the interested reader :-)

Great. Thanks for your work.

I can have a look at that, but if I understand it correctly arechtype-commons is still required so a dependency-exclusion cannot be derived from the fact that it is provided somewhere else but I have to know that the code really does not access the dependency? This requires much better knowledge of what is exactly happening in the code. Therefore I would consider this 'dangerous' and would only exclude the groovy/ivy jars because they are by far the largest once. For the few kilobytes the other jars have, I would not risk having runtime-errors due to failed class-loading.

@laeubi
Copy link
Member Author

laeubi commented Jun 15, 2022

but I have to know that the code really does not access the dependency?

correct

This requires much better knowledge of what is exactly happening in the code.

You could remove a dependency, generate the metadata and then run ArtefactManagerTest as a first iteration.

Therefore I would consider this 'dangerous'

Why? The code path is well covered by tests and these instantly fail if you remove too much, so don't worry too much.

@HannesWell
Copy link
Contributor

Therefore I would consider this 'dangerous'

Why? The code path is well covered by tests and these instantly fail if you remove too much, so don't worry too much.

That's good then and not to worry about.

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

Successfully merging this pull request may close these issues.

3 participants