-
Notifications
You must be signed in to change notification settings - Fork 446
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
Archetype for java library (JavaLibPackaging?) #723
Comments
Hmm, there is also a question: how can I modify default app_classpath? It seems that there is no way to add custom classpath into app start script – I want to add /usr/lib/actor/* to classpath. |
This is a feature we have long been discussing and is wanted by a lot of users with different packaging systems (docker, rpm, debian). If I understood you correctly the main idea is to create a new archetype
There are a few things we must take care of for this feature
Pull Requests are very welcome :) |
You can add things to the classpath with the scriptClasspath setting. There are two archetypes handling this problem. |
For me declaring an option like
I don't see any difference with rpm but docker is a big question. Right now we use docker in one of our enterprise deployment and we resolved problem in the following way:
We ended up creating complete separate project without dependency on the main project. |
It is a blocker issue for us and until tomorrow we will develop some internal solution for deb packaging. |
I think this is a good starting point as this is the most general way ( you can always integrate a separate project as an sbt-submodule). Also your solution with docker is the one that has come up in other discussions about this topic. Regarding the implementation I think we shouldn't go for Because as you said we have to configure the // build.sbt in the lib project
name := "my-libraries"
enablePlugins(JavaLibArchetype)
javaLibraryPath in Debian := Some(s"/usr/lib/${packageName.value}")
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// build.sbt in your main project
name := "my-project"
enablePlugins(JavaAppArchetype, JavaExternalDependenciesArchetype)
javaLibraryPath in Debian := Some(s"/usr/lib/my-libraries")
WDYT? |
ok, I got it. |
Awesome! Looking forward to it :) If you need any help, don't hesitate to ask. There is a developer guide that describes how to run tests and build the docs |
Also see #368 |
ok. A bit delayed here, still on my way. |
Questions from gitter:
|
To make sure I understood your questions correctly, I will try answer them by using this example setup:
Both projects are separate, one carrying only the application code, assuming all dependencies are available in the library path. So you have either
First of all, we shouldn't try to do any jar-collision-detection. This is way to complex and error prone. However I'm not sure I understand the problem correctly. Why should there be any collision? If I install my example project, I would have
And my startscript will have a classpath like this So if I install another app (
why that? I haven't looked into the linux mappings for quite some time. |
Currently working on this feature, I stuck with implementation. Here is function that returns dependencies of JavaLib projects with absolute path, as they will appear in main package's classpath. And here is usage of it. https://github.com/rockjam/sbt-native-packager/blob/97d5890bc2185a5f80b9f26de8ceb4e4a83ee5a2/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaExternalDeps.scala#L75 I know it is wrong usage, but I also tried to solve it other way. Usually I get Can someone tell me, is there something fundamentally wrong in defenition of |
I recommed not using the // defintion
def javaLibsAbsolutePath: Def.Initialize[Def.Initialize[Task[Seq[String]]]] =
(sbt.Keys.buildDependencies, sbt.Keys.thisProjectRef, sbt.Keys.state) apply { (build, thisProject, stateTask) => ???
// call site
scriptClasspath <<= (javaLibsAbsolutePath) map { v =>
v.value
}, I would recommend changing it to // definition
def javaLibsAbsolutePath(build: BuildDependencies, thisProject: ProjectRef, stateTask: State): Seq[String] = {
}
// call site
scriptClasspath := javaLibsAbsolutePath(buildDependencies.value, thisProjectRef.value, state.value) This approach has a few pros that I found very usefull
I will try to look a bit closer at your current working state and give feedback if I am able to. |
It's still work in progress, I will certainly make cleanup in code, and improve code reuse, when got working solution. |
Thanks for advice! |
Well, leaving all sbt magic in AutoPugin really helped to make code easier, but anyway I couldn't solve Illegal reference issue. Latest commit in branch issue-723 reflects current state. |
I will try to run your code ASAP |
👍 Thanks |
@rockjam I think I found the solution. See sbt/sbt#780 Def.settingDyn {
sourceDirectories.all( ScopeFilter(configurations = confFilter.value) )
} |
@muuki88 Here is a project tree:
in
in
in
|
@rockjam this looks exactly how I hope the API can look like. |
@rockjam do you need more help on this? |
@muuki88 Hello. I am responsible for this task now :) Could you be more specific on how the |
I haven't used it myself :( Just found the sbt issue. |
Our platform uses sbt-native-packager for deb packaging its core functionality. It also has an ability to load third-party or enterprise modules by specifying their fqcn's in server config. The problem is that JavaAppPackaging archetype assumes that packaged project have to be "started" via start script and that it also has a configuration.
What would you say if we implement JavaLibPackaging which would only put jar's in
/usr/lib/<appname>
(appname – not libname) and send PullRequest to you?The text was updated successfully, but these errors were encountered: