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

Shade platform specific libraries into a single jar #33

Closed
wants to merge 1 commit into from

Conversation

cconroy
Copy link
Contributor

@cconroy cconroy commented Mar 17, 2015

  • Split architecture specific libraries into their own artifacts with
    os-arch classifiers.
  • Store libs under META-INF/native/${os.classifier}/
  • Creates a "java" classifier for the Java JNI bindings
  • Shade all supported platforms together with Java source for the main
    artifact.

#24

@cconroy
Copy link
Contributor Author

cconroy commented Mar 17, 2015

Companion netty PR: netty/netty#3502

A Mavenized fork of Tomcat Native which incorporates various patches.

Building this artifact produces a native library with a classifier matching the
os/arch of the build machine. (The Java JNI bindings are exported with the 'java' classifier)
Copy link
Member

Choose a reason for hiding this comment

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

move the (...) stuff before the .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, i'll just remove the parens

@normanmaurer
Copy link
Member

@cconroy please address my comments

@cconroy
Copy link
Contributor Author

cconroy commented Mar 17, 2015

@trustin @normanmaurer one thing I meant to call out: In our discussion on the issue @trustin noted that it would make sense to keep the java classes in each architecture specific artifact to support the non-shaded use case (e.g. if a user only wants to pull in one platform).

In this PR, I have split java out into a separate artifact classifier that is built on any platform. This should address that use case while avoiding duplicate class files.

</configuration>
</execution>
<execution>
<!-- Also produce a jar with 'java' classifier. This can be built on any platform. -->
Copy link
Member

Choose a reason for hiding this comment

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

I thought we build the JAR without native libraries with no classifier already? Could you explain why we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Under this model, the non-classified jar is produced by the shade pom to produce a jar that can be used on any platform. Here, the antrun plugin produces the platform-specific jar. This extra execution tells maven to package up the normal target results as a 'java' package.

@trustin
Copy link
Member

trustin commented Mar 18, 2015

I like the idea of providing a shaded JAR that contains all native libraries. How about:

  • Make the netty-tcnative jar with no classifier (the default jar) include all supported native libraries. i.e. most users can just pull the default JAR and that should be all.
  • Keep the JARs with the OS classifiers as before.

One problem I see with the shade/pom.xml is that the maven release plugin will not update the version number of shade/pom.xml. (i.e. They can get out-of-sync pretty easily.) How would you fix this problem?

@trustin trustin added this to the 1.1.32.Fork2 milestone Mar 18, 2015
@cconroy
Copy link
Contributor Author

cconroy commented Mar 18, 2015

@trustin: i'm not too familiar with the maven release plugin. Unfortunately, maven does not let me use a property as a version tag. I'll dig around to see what I can find... At the very least we could have a clear README with release steps or perhaps a shell script to automate?

@cconroy
Copy link
Contributor Author

cconroy commented Mar 18, 2015

"Make the netty-tcnative jar with no classifier (the default jar) include all supported native libraries. i.e. most users can just pull the default JAR and that should be all."

Yep! This is what happens when you run the shaded target. I encourage you to try it out (you can test locally by commenting out the other platforms to just shade your local platform after building the platform-specific libs).

@cconroy
Copy link
Contributor Author

cconroy commented Mar 18, 2015

"Keep the JARs with the OS classifiers as before."

IMHO it's cleaner to separate the java and platform-specific artifacts for those users that don't want the shaded jar. I would personally prefer to add a second dep rather than get duplicate class files.

Historically I've seen build failures and other problems (e.g. with IDEs, other build integration tools) occur with duplicate classes. Most users will probably not care about a slightly larger jar and will just use the shaded one anyways. We should add documentation to clarify how to depend on a single platform.

If you're okay with keeping them separate, I can update the readme to reflect. If not, I can try to spin a version with duplicate classes.

@cconroy
Copy link
Contributor Author

cconroy commented Mar 25, 2015

@trustin: realistically, i don't think you probably want to update the shade and platform specific numbers at the same time. You'll be releasing platform specific libs from the same platform machines. Once all of those are updated, you'll want to do a shade release. I don't see a path for doing this automatically with the release plugin.

@trustin
Copy link
Member

trustin commented Mar 26, 2015

@cconroy Agreed. The build process of the all-platform JAR will be more like fetching & merging all JARs of the already-deployed JARs. I guess we don't need a pom for this. Just a shell script should do the job. Let apply your changes partially and write one.

@netkins
Copy link

netkins commented Apr 2, 2015

AUTOMATED MESSAGE for ADMINS:
Please verify and accept the pull request.
To accept, say @netkins accept
To build again, say @netkins build
To whitelist the author, say @netkins whitelist

@cconroy
Copy link
Contributor Author

cconroy commented Apr 22, 2015

This should be good to merge?

@cconroy
Copy link
Contributor Author

cconroy commented Apr 27, 2015

@trustin @normanmaurer ping

@cconroy
Copy link
Contributor Author

cconroy commented May 4, 2015

@trustin @normanmaurer can we please merge this?

@normanmaurer
Copy link
Member

Sorry will check tomorrow... Busy as hell :/

Am 04.05.2015 um 23:19 schrieb cconroy notifications@github.com:

@trustin @normanmaurer can we please merge this?


Reply to this email directly or view it on GitHub.

@trustin
Copy link
Member

trustin commented May 5, 2015

@cconroy @normanmaurer I'll take care of this as well as the NativeLibraryLoader changes in Netty. I don't have time at the moment, either, but I wanna resolve this by myself. Sorry for the delay and thanks for your patience.

@louiscryan
Copy link

Now that we have the statically linked boring ssl artifacts I'd like to bring up what we think the 'default' artifact should be. We theoretically have

{platforms} X [openssl, libre, boring] X [dynamic, static]

Based on the current plan a mega jar with boring-static is the library most likely to work out of the box for all features for developers when compared to a shared openssl one. Switching to this however can't be done without a certain amount of messaging.

In particular the lifecycle around managing security patches to openssl interacts with this decision as sys admins may have the latent expectation that updating shared openssl is their primary tool for resolving security issues. I suppose most admins have become used to updating Java to resolve issues too so this may be less of a concern if we were to switch to boring-static as the default but its worth mentioning.

@nmittler
Copy link
Member

Hey guys,
Based on the recent work for creating statically-linked libraries, I've created a similar PR: #113.

Let's discuss.

@trustin
Copy link
Member

trustin commented Feb 17, 2016

@nmittler Thank you so much for taking a stab on this!

@johnou
Copy link
Contributor

johnou commented Mar 11, 2016

@cconroy now that @nmittler has broken the ice how would you go about adapting this pull request to support other libraries such as openssl dynamic fedora etc. I have an open PR on the netty side here netty/netty#4925

@cconroy
Copy link
Contributor Author

cconroy commented Apr 5, 2016

@johnou This pull request is over a year old despite having general agreement on the approach so any other changes should probably be done in a subsequent PR

@normanmaurer any updates here?

@normanmaurer
Copy link
Member

@nmittler I think we can close this now as we have the boringssl static uberjar. WDYT ?

@nmittler
Copy link
Member

Yeah sgtm ... closing.

@nmittler nmittler closed this May 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants