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

Jetty 12.0.x refactor common maven plugin classes #11651

Merged

Conversation

janbartel
Copy link
Contributor

Refactor all eeX jetty maven plugins to extract common code.

joakime and others added 30 commits March 13, 2024 12:02
Renaming to Hidden/Protected
# Conflicts:
#	jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppContext.java
…lassLoading.java

Co-authored-by: Jan Bartel <janb@webtide.com>
swapped defaults to environment
added unit tests
@janbartel janbartel self-assigned this Apr 12, 2024
@janbartel janbartel marked this pull request as ready for review April 22, 2024 05:44
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test dependencies are not needed as there are no tests in this module

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should be some tests added at some point.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but not yet. better keep it clean for what we do not need

Copy link
Member

@olamy olamy Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will probably/certainly never have tests here :)

<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no test here so not needed

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven</artifactId>
<optional>true</optional>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why optional? seems to be mandatory to have it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the others are optional, so I made it the same. But happy to make it mandatory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same dependency is not optional in ee9 :)
and btw it is really used by the maven plugin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made ee9 optional too, so that they all match.

And yes, this dependency is where all the classes are that are common across ee8/9/10 versions of the plugin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made ee9 optional too, so that they all match.

And yes, this dependency is where all the classes are that are common across ee8/9/10 versions of the plugin.

if it's really used and not depending on what the user will use it's mandatory to have it and not optional.
most of the optional dependencies looks wrong to be optional (but it's not something new I agree :))
why jetty-util is not optional whereas jetty-server is optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these were maybe made optional because of the distro way of running the plugin: when we set up the fork for jetty home, we need to copy over any <dependencies> that are configured on the <plugin> so the webapp works. We put out a warning if there are any dependencies that are jetty dependencies (because you shouldn't be adding any jetty dependencies to the plugin). The thinking might have been that these dependencies of the plugin itself might register as dependencies (of the project that uses the plugin) and therefore trigger the warning. See the code here: https://github.com/jetty/jetty.project/blob/jetty-12.0.x/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/AbstractWebAppMojo.java#L541

If you're sure that the dependencies of the plugin itself won't register as dependencies of the usage of the plugin, then we can probably take these optionals out (although the optional setting should only affect people who are trying to use the jetty maven plugin project as a dependency on their own project, which doesn't really make a lot of sense).

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven</artifactId>
<optional>true</optional>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need this for jetty-home?

Copy link
Contributor Author

@janbartel janbartel Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be where all the core modules are incorporated into the distro, so yes because there are some classes/modules that are used when the jetty maven plugin starts in distro mode so they have to be part of the distro.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it;s used only by the maven plugins and they are not part of the distribution so it's not needed to be included in the jetty-home.

Copy link
Contributor Author

@janbartel janbartel Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@olamy olamy Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah right those modules which are not part of distro but added dynamically when using the maven plugin.
well currently the jar looks to be copied already as plugin.jar in lib/maven-ee10/*.jar via


the mod file looks to need to be only

[lib]
lib/maven-ee10/*.jar

as the jar will be added and named plugin.jar

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argh. not sure how to do something such

[lib]
${{jetty.base}/lib/maven-ee10/*.jar

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ${jetty.base} portion (btw you have a typo in yours) isn't necessary.
That location will be looked for in all of the configuration sources that are directories that the start.jar is aware of (eg: ${jetty.base} then ${jetty.home}, but you can also add more directories between those two locations via a --add-config-dir=<dir> command line)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's weird I have

[lib]
${jetty.base}/lib/maven-ee10/*.jar

And

olamy@pop-os:~/dev/sources/jetty/jetty.project$ ls -lrt jetty-ee10/jetty-ee10-maven-plugin/target/it/jetty-start-war-distro-mojo-it/jetty-simple-webapp/target/jetty-base/lib/maven-ee10/
total 88
-rw-rw-r-- 1 olamy olamy 86660 Apr 26 09:14 plugin.jar

But sill CNFE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the code to remove the jetty-maven.jar from the distro, and dynamically copied it over into the ${jetty.base}/lib/${ee}-maven directory as is done for the jetty-$ee}-maven-plugin.jar.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. haha I just saw my confusion regrading the file :)

@janbartel janbartel requested a review from olamy April 25, 2024 06:59
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
Copy link
Member

@olamy olamy Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will probably/certainly never have tests here :)

Copy link
Member

@olamy olamy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still some dependencies non needed and with probably wrong scope but it has been like this for years :) and we can live with that.
we can address the non needed test dependencies later

@joakime joakime merged commit e9c71be into jetty-12.0.x Apr 26, 2024
6 of 9 checks passed
@joakime joakime deleted the jetty-12.0.x-refactor-common-maven-plugin-classes branch April 26, 2024 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants