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

[BUILD] Separate transitive dependencies in core #1124

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

FKHals
Copy link
Contributor

@FKHals FKHals commented Feb 19, 2021

so that the core can act as a dependency-container without leaking it's
own (non-transitive) dependencies into the classpaths of the packages
importing it while still providing the transitive dependencies that
are needed by those packages.

This is implemented by creating the two new configurations "bundle" and
"bundleApi" which replace the previously used "releaseDep".
Dependencies of the "bundle"-configuration gets extend from the
"implementation"-configuration (by the gradle-java-plugin) which is not
transitive and therefore it's dependencies are only visible to the core
package itself while the dependencies in "bundleApi" (which the
corresponding "api"-config extends from) can be used by all packages
that import the core.
Extension in the context of configurations means that that all the
dependencies in the "bundle"-config also get added to the
"implementation"-config.

This solution has the advantage to other solutions (e.g. creating a new
OSGI package) that the complexity of the build system is not
significantly increased and no versioning of any additional OSGI
packages needs to be considered.

The solution was proposed and kindly explained to the authors by
@m273d15 following the PR #1118.

@FKHals FKHals force-pushed the pr/core-dependency-container branch from 9d53234 to fd07483 Compare February 19, 2021 20:48
Copy link
Contributor

@m273d15 m273d15 left a comment

Choose a reason for hiding this comment

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

Nice!
Your PR contains only the Gradle changes. I would expect that you also need to adjust the META-INF/MANIFEST.MF file and remove entries that export libraries that are not part of the API (for example commons-codec in the core). Do you plan follow-up PRs that get rid of the remaining API/exported dependencies (for example commons-io)?

stf/build.gradle.kts Outdated Show resolved Hide resolved
stf/build.gradle.kts Show resolved Hide resolved
@FKHals FKHals force-pushed the pr/core-dependency-container branch 2 times, most recently from 8a1167a to b206993 Compare February 22, 2021 11:57
@FKHals
Copy link
Contributor Author

FKHals commented Feb 22, 2021

Nice!
Your PR contains only the Gradle changes. I would expect that you also need to adjust the META-INF/MANIFEST.MF file and remove entries that export libraries that are not part of the API (for example commons-codec in the core). Do you plan follow-up PRs that get rid of the remaining API/exported dependencies (for example commons-io)?

We have done the proposed fixes (and also moved xstream, jmdns and xpp3 to bundle instead of bundleApi) including the removal of the unnecessary exports in the MANIFEST.MF. Our goal is to contain all the changes in this (hopefully coherent) commits so we do not plan any follow ups. Anything that we have not done yet is probably an error/oversight on our side and we are glad to fix it if more problems get pointed out.

Since commons-io seems to get used by the server (in server/src/saros/server/editor/Editor.java and others) we did not think it would be possible to also exclude it from the exported dependencies. Or does the server somehow get its dependencies differently?

Eik0fresh and others added 4 commits February 22, 2021 13:59
so that the core can act as a dependency-container without leaking it's
own (non-transitive) dependencies into the classpaths of the packages
importing it while still providing the transitive dependencies that
are needed by those packages.

This is implemented by creating the two new configurations "bundle" and
"bundleApi" which replace the previously used "releaseDep".
Dependencies of the "bundle"-configuration gets extend from the
"implementation"-configuration (by the gradle-java-plugin) which is not
transitive and therefore it's dependencies are only visible to the core
package itself while the dependencies in "bundleApi" (which the
corresponding "api"-config extends from) can be used by all packages
that import the core.
Extension in the context of configurations means that that all the
dependencies in the "bundle"-config also get added to the
"implementation"-config.

This solution has the advantage to other solutions (e.g. creating a new
OSGI package) that the complexity of the build system is not
significantly increased and no versioning of any additional OSGI
packages needs to be considered.

This commit includes just the preparations for the following commits
that actually make this happen. So at this moment the new configs
just get extended from the old "releaseDep" for compatibility
reasons (this will change in the following commits).

The solution was proposed and kindly explained to the authors by
@m273d15 following the PR saros-project#1118.

Co-authored-by: FKHals <30548867+FKHals@users.noreply.github.com>
Co-authored-by: paun42 <75132590+paun42@users.noreply.github.com>
Co-authored-by: panphil <74254708+panphil@users.noreply.github.com>
to use the "bundle" and "bundleApi" as configurations instead of "releaseDep".

Co-authored-by: Eik0fresh <39055879+Eik0fresh@users.noreply.github.com>
Co-authored-by: paun42 <75132590+paun42@users.noreply.github.com>
Co-authored-by: panphil <74254708+panphil@users.noreply.github.com>
to use the "bundle" and "bundleApi" as configurations instead of "releaseDep".

Co-authored-by: Eik0fresh <39055879+Eik0fresh@users.noreply.github.com>
Co-authored-by: paun42 <75132590+paun42@users.noreply.github.com>
Co-authored-by: panphil <74254708+panphil@users.noreply.github.com>
and remove the last remains of the previous default configuration
"releaseDep".

Co-authored-by: Eik0fresh <39055879+Eik0fresh@users.noreply.github.com>
Co-authored-by: paun42 <75132590+paun42@users.noreply.github.com>
Co-authored-by: panphil <74254708+panphil@users.noreply.github.com>
@FKHals FKHals force-pushed the pr/core-dependency-container branch from b206993 to d8dba44 Compare February 22, 2021 13:00
@m273d15
Copy link
Contributor

m273d15 commented Feb 23, 2021

Since commons-io seems to get used by the server (in server/src/saros/server/editor/Editor.java and others) we did not think it would be possible to also exclude it from the exported dependencies. Or does the server somehow get its dependencies differently?

You could simply add the dependency as a Gradle dependency of the server project. This is the intended way of handling dependencies. Instead of relying on the transitive dependencies of another project, the server defines its own dependencies.

and instead let every project get it by itself, since it is not part
of the cores public api and it further reduces the coupling between
the core and these projects.

We decided that this should be a separate commit from the previous
ones (that also change the build-system) since it changes different
files and could not be integrated coherently.

Co-authored-by: Eik0fresh <39055879+Eik0fresh@users.noreply.github.com>
Co-authored-by: paun42 <75132590+paun42@users.noreply.github.com>
Co-authored-by: panphil <74254708+panphil@users.noreply.github.com>
@FKHals FKHals force-pushed the pr/core-dependency-container branch from c3fde89 to 7afa9b1 Compare February 24, 2021 08:28
@FKHals
Copy link
Contributor Author

FKHals commented Feb 24, 2021

We just made the changes so that commons-io won't get exported by the core and instead gets imported by every project for itself. We are still testing/researching if this could be done with commons-lang too, but the tests still fail at the moment.

Edit: For some reason the STF tests of both commits seem to fail..

and instead let every project get it by itself, since it is not part
of the cores public api and it further reduces the coupling between
the core and these projects.

Co-authored-by: Eik0fresh <39055879+Eik0fresh@users.noreply.github.com>
Co-authored-by: paun42 <75132590+paun42@users.noreply.github.com>
Co-authored-by: panphil <74254708+panphil@users.noreply.github.com>
@FKHals
Copy link
Contributor Author

FKHals commented Feb 24, 2021

Is there any reason why the commons-io-entries still need to be listed in Export-Packages for the STF-tests to work even if the commons-io-package itself is in the cores bundle-configuration and therefore should not be exposed anyways?

I just confirmed on a testing branch at our fork that this seems to be the case since the tests succeed when the Export-Packages-entries are present.

@@ -4,28 +4,7 @@ Bundle-Name: Saros Core
Bundle-SymbolicName: saros.core
Bundle-Version: 0.2.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: com.thoughtworks.xstream,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you remove the exports ?

Choose a reason for hiding this comment

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

The xstream-Package is only used by the core and no other bundle. So the core don't need to export this package. If any other bundle is using this package and we missed to find it, please tell us that.

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.

None yet

4 participants