sbt / sbt-osgi Goto Github PK
View Code? Open in Web Editor NEWsbt plugin for creating OSGi bundles
License: Apache License 2.0
sbt plugin for creating OSGi bundles
License: Apache License 2.0
The bnd tools supports the -include
directive, to read additional headers and directives from a file. How can I configure sbt-osgi to read some headers / directives from a bnd.bnd
file?
My build emits the following error:
[error] bnd: The Bundle Activator moduleB.internal.MyDominoActivator does not implement BundleActivator.
Please find a project which shows this happening:
https://github.com/frgomes/domino-osgi-sample
More details here: frgomes/domino-osgi-sample#1
Hi,
would it be possible to add a 0.13 version for sbt for testing ?
Thanks
For the snapshot version, this import does not work. Following the instructions for the snapshot version does not work.
import com.typesafe.sbt.SbtOsgi.autoImport._
I am importing sbt-osgi to my project using the git link in my local project's plugins.sbt file.
Here are the contents of my plugins.sbt file:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
lazy val plugins = (project in file("."))
.dependsOn(sbtOsgi)
def sbtOsgi = uri("git://github.com/sbt/sbt-osgi.git")
With that in my build, I can run "sbt compile" and "sbt eclipse" without any trouble. When I add "osgiSettings" with a blank line before it to the end of my build.sbt, I get the following:
Reference to undefined setting:
*:osgiBundle from compile:packageBin::packagedArtifact (C:\dev\myproject\build.sbt:18)
at sbt.Init$class.Uninitialized(Settings.scala:270)
at sbt.Def$.Uninitialized(Def.scala:10)
Is there something wrong with the way that I configured my project, or is this a problem with the plugin?
I mapped some jars in EmbbedJars key. The plugin generate the jars in bundle jar, however, he don't generate the embed-dependency and embedded-artifacts in Manifest.MF.
The current unit test coverage for the plugin is rather poor. bundleTask
is not covered at all, and that's where most of the work is done. bundleTask
should be broken up into smaller, testable chunks, with unit tests written for each chunk. Ideally, an end-to-end test for bundleTask
should also be written.
[info] [info] Validating all packages are set private or exported for OSGi explicitly...
[info] [success] Total time: 1 s, completed Aug 12, 2017 1:49:18 AM
[error] x sbt-osgi / test-08-failOnClassesExcludedFromJarStar
[error] {line 1} Command succeeded but failure was expected
[trace] Stack trace suppressed: run last *:scripted for the full output.
[error] (*:scripted) Failed tests:
[error] sbt-osgi / test-08-failOnClassesExcludedFromJarStar
[error] Total time: 27 s, completed Aug 12, 2017 1:49:19 AM
The defaults from the maven bundle plugin (see the section "Default Behavior" here: http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html) are pretty intuitive and anyone who has used maven-bundle-plugin (which is pretty much everyone in the java/osgi world) will be familiar with them.
I suggest that SBT-OSGi should re-use the same defaults, as a principle of least surprise, and since they do make good intuitive sense.
@jroper requested it to be released for 0.13
It seems it needs code changes sadly.
I know this is maybe not the way "most" people would treat OSGI.
But actually in addition to osgiExplodedJars
and osgiEmbeddedJars
it would be great to actually have a setting that will automatically add every compile time + transitive compile time dependency to the jar, some kind of shading.
Planning to use sbt-github-actions since the build is trivial and it greatly reduces maintenance burden unless @eed3si9n has objections.
The current direct translation from Scala-style version numbers (as used for publishing in Maven repositories) to OSGi version numbers makes it difficult to get import version ranges right.
For instance, this is what we now do in slick-extensions:
OsgiKeys.importPackage := Seq(
osgiImport("scala.slick*", slickVersion, requireMicro=true),
osgiImport("scala*", scalaVersion.value),
"*"
)
Where osgiImport
is defined as:
/** Create an OSGi version range for standard Scala / Typesafe versioning
* schemes that describes binary compatible versions. */
def osgiVersionRange(version: String, requireMicro: Boolean = false): String =
if(version contains '-') "${@}" // M, RC or SNAPSHOT -> exact version
else if(requireMicro) "${range;[===,=+)}" // At least the same micro version
else "${range;[==,=+)}" // Any binary compatible version
/** Create an OSGi Import-Package version specification. */
def osgiImport(pattern: String, version: String, requireMicro: Boolean = false): String =
pattern + ";version=\"" + osgiVersionRange(version, requireMicro) + "\""
This means that slick-extensions 2.0.2
imports slick [2.0.2,2.1)
and slick-extensions 2.1.0
imports slick [2.1.0,2.2)
, which are the defined binary compatible versions. When we look at non-release versions (which have no binary compatibility guarantees), this also works fine: slick-extensions 2.1.0.M1
imports slick 2.1.0.M1
.
Combining either multiple release versions, or multiple non-release versions in a container also poses no problems, but things break down when you try to mix release and non-release versions like slick-extensions 2.1.0.M1 and 2.1.0 because 2.1.0.M1
is matched by [2.1.0,2.2)
even though it is incompatible and older than 2.1.0.
I think sbt-osgi would be a good place to solve this for all Scala libraries. It could translate the version from the sbt build to an OSGi version for the bundle and the exported packages, and do the same to dependency versions (or is that fully handled by bnd?).
I have some ideas how a suitable version number scheme could look but I'm sure this problem has already been solved by the OSGi community, so I'll leave it to others to suggest something.
As far as I can tell, the challenges are:
[==,+)
can be used.Is there a way to create a fat jar using the OsgiKeys.embeddedJars
attribute, but to exclude libraries that are marked as "Provided", like e.g.:
libraryDependencies += "org.apache.logging.log4j" % "log4j-api" % "2.7" % Provided
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % akkaVersion
In this case com.typesafe.akka
should be included in the fat jar while org.apache.logging.log4j
should not be compiled into the jar.
Given the poor handling of the recent security incident (https://arstechnica.com/information-technology/2021/09/travis-ci-flaw-exposed-secrets-for-thousands-of-open-source-projects/) I'm suspending Travis CI integration indefinitely.
Let's move on to GitHub Actions.
The generated Manifest ist missing version information for those imported packages that come from other sub-projects (which are added via sbt's project.dependsOn
syntax). It looks like sbtOsgi only sees the class files but not the generated manifests. Packages comming from libraryDependencies
properly get their version information extracted and added to the Import-Package
header.
I've just tried to upgrade to 0.9.4 in my sbt 0.13 build and it bombed saying it couldn't find the plugin.
A quick look here https://dl.bintray.com/sbt/sbt-plugin-releases/com.typesafe.sbt/sbt-osgi/scala_2.10/sbt_0.13/ suggests there are artefacts for 0.9.[0-3] but 0.9.4 is missing.
As a consequence of #95, its possible to create an infinite recursive loop which means that sbt never ends up fully starting.
To reproduce this, simply change https://github.com/sbt/sbt-osgi/blob/main/src/main/scala/com/typesafe/sbt/osgi/SbtOsgi.scala#L47 to (fullClasspath in Compile).value.map(_.data)
and then navigate into src/sbt-test/sbt-osgi/test-05-exportJars/
to run the test (i.e. run sbt osgiBundle
).
You will notice that sbt stalls forever, failing to start. My suspicion is that there is an interdependency between
bundle := Osgi.bundleTask
(fullClasspath in Compile).value.map(_.data)
Compile / sbt.Keys.packageBin := bundle.value
Which causes the sbt task graph to not complete when evaluated. Apparently the intention of #95 was to prevent asynchronicity issues (see #79 (comment)) by forcefully evaluating Compile / sbt.Keys.packageBin
.
@romainreuillon Maybe there is a better way to solve this otherwise I think I would have to revert the change since you can easily prevent sbt from even starting.
scala-steward suggested I upgrade to 0.9.5, so it apparently exists, but https://github.com/sbt/sbt-osgi/releases lacks release notes for it
I am trying get the xml generated for DS in conjunction with the org.osgi.service.component.annotations._
components (so not the aQute.bnd
ones). Is this supported, aren't the instructions just passed onwards to bnd?
I have tried adding
OsgiKeys.additionalHeaders := Map(
"_dsannotations" -> "*"
)
Working with version 0.7.0
tx
In Akka, we publish OSGi bundles by replacing the packageBin
task:
Compile / packageBin := OsgiKeys.bundle.value
The advantage is that this way the bundle will be picked up correctly by other plugins publishing the packaged artifacts.
A nonobvious effect of this approach is that this will render customizations of the packageBin
task, such as changing Compile / packageBin / mappings
, ineffective.
Do we want to document/encourage publishing packages like this? Are there alternative solutions? If we recommend this, should we try to be as faithful as possible to the default packageBin
behavior and try to honour the mappings
?
Dear Devs,
it seems that sbt-osgi has vanished from the maven central repo:
https://repo1.maven.org/maven2/com/typesafe/sbt/
Any idea what happened?
Best,
Romain
Looks like there have been releases for v0.9.0 and v0.9.1, but those tags are missing.
@ktoso looks like you cut those releases. Could you push the relevant tags please?
The race is very well analyzed in this issue, so please read that issue completely.
The issue was introduces as part of this change
Some known documented occurence of this issue are
The applied workaround in these issues was to downgrade to sbt-osgi 0.9.4, but said version does not work with Java 17 and newer.
Here are some solutions:
Import-Package
statements. This is effectively a way to switch #64 on and off. We could default to off
. Also, it should come with some documentation.So I did some digging to figure out the root cause of apache/pekko#757 and I managed to bisect the change which caused the regression which happens to be #64 . When using
log.info("CONTENT IS")
log.info(content.mkString("\n"))
at https://github.com/sbt/sbt-osgi/blob/main/src/main/scala/com/typesafe/sbt/osgi/Osgi.scala#L186 and sbt protobuf-v3/osgiBundle
within pekko to diagnose the content that is being packaged, without #64 you get
[info] CONTENT IS
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/BufferAllocator.class,org/apache/pekko/protobufv3/internal/BufferAllocator.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/ApiOrBuilder.class,org/apache/pekko/protobufv3/internal/ApiOrBuilder.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/RepeatedFieldBuilderV3$MessageExternalList.class,org/apache/pekko/protobufv3/internal/RepeatedFieldBuilderV3$MessageExternalList.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/Protobuf.class,org/apache/pekko/protobufv3/internal/Protobuf.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache,org/apache)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/DescriptorProtos$EnumOptions.class,org/apache/pekko/protobufv3/internal/DescriptorProtos$EnumOptions.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/NewInstanceSchemaFull.class,org/apache/pekko/protobufv3/internal/NewInstanceSchemaFull.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/CanIgnoreReturnValue.class,org/apache/pekko/protobufv3/internal/CanIgnoreReturnValue.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/SourceContextOrBuilder.class,org/apache/pekko/protobufv3/internal/SourceContextOrBuilder.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/StringValue$1.class,org/apache/pekko/protobufv3/internal/StringValue$1.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/CodedInputStream$1.class,org/apache/pekko/protobufv3/internal/CodedInputStream$1.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/EmptyOrBuilder.class,org/apache/pekko/protobufv3/internal/EmptyOrBuilder.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/DescriptorProtos$MessageOptionsOrBuilder.class,org/apache/pekko/protobufv3/internal/DescriptorProtos$MessageOptionsOrBuilder.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/Method.class,org/apache/pekko/protobufv3/internal/Method.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/RpcController.class,org/apache/pekko/protobufv3/internal/RpcController.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/UninitializedMessageException.class,org/apache/pekko/protobufv3/internal/UninitializedMessageException.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/DescriptorProtos$SourceCodeInfo$Location$1.class,org/apache/pekko/protobufv3/internal/DescriptorProtos$SourceCodeInfo$Location$1.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/CheckReturnValue.class,org/apache/pekko/protobufv3/internal/CheckReturnValue.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/UInt32ValueOrBuilder.class,org/apache/pekko/protobufv3/internal/UInt32ValueOrBuilder.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/BinaryWriter$UnsafeHeapWriter.class,org/apache/pekko/protobufv3/internal/BinaryWriter$UnsafeHeapWriter.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/DescriptorProtos$EnumValueOptionsOrBuilder.class,org/apache/pekko/protobufv3/internal/DescriptorProtos$EnumValueOptionsOrBuilder.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/Syntax$1.class,org/apache/pekko/protobufv3/internal/Syntax$1.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/ByteString$2.class,org/apache/pekko/protobufv3/internal/ByteString$2.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/Int32Value$Builder.class,org/apache/pekko/protobufv3/internal/Int32Value$Builder.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/Option.class,org/apache/pekko/protobufv3/internal/Option.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/DynamicMessage.class,org/apache/pekko/protobufv3/internal/DynamicMessage.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/Type.class,org/apache/pekko/protobufv3/internal/Type.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/DescriptorProtos$MessageOptions$1.class,org/apache/pekko/protobufv3/internal/DescriptorProtos$MessageOptions$1.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/ListFieldSchema.class,org/apache/pekko/protobufv3/internal/ListFieldSchema.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/MessageInfoFactory.class,org/apache/pekko/protobufv3/internal/MessageInfoFactory.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/MapEntryLite$Metadata.class,org/apache/pekko/protobufv3/internal/MapEntryLite$Metadata.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/type.proto,google/protobuf/type.proto)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/Int32Value.class,org/apache/pekko/protobufv3/internal/Int32Value.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/TimestampProto.class,org/apache/pekko/protobufv3/internal/TimestampProto.class)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/org/apache/pekko/protobufv3/internal/Duration$1.class,org/apache/pekko/protobufv3/internal/Duration$1.class)
... (truncated)
where as with #64 you get
[info] CONTENT IS
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir,)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google,google)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf,google/protobuf)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/timestamp.proto,google/protobuf/timestamp.proto)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/field_mask.proto,google/protobuf/field_mask.proto)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/api.proto,google/protobuf/api.proto)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/duration.proto,google/protobuf/duration.proto)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/struct.proto,google/protobuf/struct.proto)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/wrappers.proto,google/protobuf/wrappers.proto)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/source_context.proto,google/protobuf/source_context.proto)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/any.proto,google/protobuf/any.proto)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/type.proto,google/protobuf/type.proto)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/empty.proto,google/protobuf/empty.proto)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/compiler,google/protobuf/compiler)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/compiler/plugin.proto,google/protobuf/compiler/plugin.proto)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/google/protobuf/descriptor.proto,google/protobuf/descriptor.proto)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/META-INF,META-INF)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/META-INF/LICENSE,META-INF/LICENSE)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/META-INF/DISCLAIMER,META-INF/DISCLAIMER)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/META-INF/COPYING.protobuf,META-INF/COPYING.protobuf)
[info] (/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/pekko-protobuf-v3_2.13-1.1.0-M0-1-SNAPSHOT.jar_tmpdir/META-INF/NOTICE,META-INF/NOTICE)
As you can see the change means that all of the .class
files end up getting stripped out of the osgi-bundle.
If we do some more digging we can see what is causing the regression, if I you do show protobuf-v3/Compile/fullClasspath
which is what was used without #64 you get
[info] * Attributed(/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/stripped/stripped/pekko-protobuf-v3-assembly-1.1.0-M0-1-SNAPSHOT.jar)
[info] * Attributed(/Users/mdedetrich/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/google/protobuf/protobuf-java/3.20.3/protobuf-java-3.20.3.jar)
where as if you do show protobuf-v3/Compile/dependencyClasspathAsJars
(which is with #64) you get
[info] * Attributed(/Users/mdedetrich/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/google/protobuf/protobuf-java/3.20.3/protobuf-java-3.20.3.jar)
The Attributed(/Users/mdedetrich/github/incubator-pekko/protobuf-v3/target/scala-2.13/stripped/stripped/pekko-protobuf-v3-assembly-1.1.0-M0-1-SNAPSHOT.jar)
happens to be missing.
This is very likely a result of the bespoke way that we generate the jar for protobuf-v3 (see https://github.com/apache/incubator-pekko/blob/main/build.sbt#L359-L387)
@lefou Since you implemented #64 you know what the underlying motivation for the change. At least on a glance to me it seems like a quick way to fix this is to combine both (dependencyClasspathAsJars in Compile).value.map(_.data) ++ (products in Compile).value
and (fullClasspath in Compile)
but use (dependencyClasspathAsJars in Compile).value.map(_.data) ++ (products in Compile).value
as a preference which should still solve the underlying problem described in #60 .
@raboof Maybe you can provide some underlying context here regarding the implementation of the protobuf-v3 sbt module.
@romainreuillon If you have time to look into this that would also be great.
I am not sure what the state of this plugin's maintenance level is.
Assuming @johanandren is ok with the idea, I can create a new GitHub team that can review and merge PRs, release to Maven Central etc like I've done with other plugins.
/cc @mkurz, @romainreuillon, @mdedetrich
We tried to move a maven-based build to sbt, using the same values. But, in our tests, when the bundleSymbolicName has a dash, the build won't find some classes (in our case, it was the bundle activator).
depends on #41
Can you please release current master as 0.9.5
. We long await the fixes it includes.
It may be sensible to discard some class files in an osgi context but doing so silently has lead to repeated release breakage (see akka/akka#18178 and akka/akka#17956).
This plugin needs a (default!) mode which fails if not all classes are exported by the configuration.
It seems the published SNAPSHOT for 0.8 doesn't include the autoPlugins infrastructure. Maybe a quick republish to fix?
See README. It is export-package
in the API, but exportPackage
in the example.
It looks like a typo.
BND output should be captured and integrated into the output of "show" when the plugin is run interactively. It's easy to misconfigure a tool like sbt-osgi, and if the user already knows bnd and could see what is being passed to it, they might have a better chance of self-diagnosing configuration issues.
At pekko we are using sbt-osgi and we have encountered a regression that occurred between 0.9.4 and 0.9.5 whereby there are duplicate classes/jars, see apache/pekko#745 (comment) for more info.
Ordinarily this regression wouldn't have been an issue since we could just stick to 0.9.4 but because of #81 0.9.4. no longer works. In the interests of unblocking pekko (currently both the main
and 1.0.x
branches are broken due to this) would it be possible to create patched release of 0.9.4. containing #81 ?
In my mind I would create a new branch based off of 0.9.4, cherry picking the relevant build/org updates along with the patch and then we can cut a release by pushing a git tag (I was thinking 0.9.4-INVALID-CEN-JAR-PATCH
?)
@eed3si9n @xuwei-k @romainreuillon thoughts?
[error] java.util.ConcurrentModificationException
[error] at java.base/java.util.TreeMap.callMappingFunctionWithCheck(TreeMap.java:750)
[error] at java.base/java.util.TreeMap.computeIfAbsent(TreeMap.java:604)
[error] at aQute.bnd.osgi.Jar.putResource(Jar.java:259)
[error] at aQute.bnd.osgi.Jar$1.visitFile(Jar.java:186)
[error] at aQute.bnd.osgi.Jar$1.visitFile(Jar.java:167)
[error] at java.base/java.nio.file.Files.walkFileTree(Files.java:2811)
[error] at aQute.bnd.osgi.Jar.buildFromDirectory(Jar.java:166)
[error] at aQute.bnd.osgi.Jar.<init>(Jar.java:109)
[error] at aQute.bnd.osgi.Jar.<init>(Jar.java:138)
[error] at aQute.bnd.osgi.Analyzer.setClasspath(Analyzer.java:1465)
[error] at com.typesafe.sbt.osgi.Osgi$.bundleTask(Osgi.scala:57)
[error] at com.typesafe.sbt.osgi.SbtOsgi$.$anonfun$defaultOsgiSettings$1(SbtOsgi.scala:55)
See more details in akka/akka#24520
In general the plugin should simply include packageOptions in the manifest, yet it ignored them
these seem to be missing from https://github.com/sbt/sbt-osgi/releases/
@romainreuillon If possible can you at some point write tests for the #100 feature. There might be a more natural mechanism (i.e. https://www.scala-sbt.org/1.x/docs/Caching.html) to do caching but its best to have a test first so we don't create regression.
sbt:pekko-bench-jmh> last actor / osgiBundle
[info] Validating all packages are set private or exported for OSGi explicitly...
[warn] bnd: Unused -privatepackage instructions , no such package(s) on the class path: [org.apache.pekko.osgi.impl]
[warn] bnd: Unused Import-Package instructions: [scala.compat.java8.*]
[error] java.util.zip.ZipException: duplicate entry: META-INF/MANIFEST.MF
[error] at java.base/java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:233)
[error] at java.base/java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:109)
[error] at sbt.io.IO$.addFileEntry$1(IO.scala:717)
[error] at sbt.io.IO$.$anonfun$writeZip$6(IO.scala:726)
[error] at sbt.io.IO$.$anonfun$writeZip$6$adapted(IO.scala:726)
[error] at scala.collection.immutable.Stream.foreach(Stream.scala:533)
[error] at sbt.io.IO$.writeZip(IO.scala:726)
[error] at sbt.io.IO$.$anonfun$archive$2(IO.scala:676)
[error] at sbt.io.IO$.$anonfun$archive$2$adapted(IO.scala:673)
[error] at sbt.io.IO$.$anonfun$withZipOutput$1(IO.scala:773)
[error] at sbt.io.IO$.$anonfun$withZipOutput$1$adapted(IO.scala:753)
[error] at sbt.io.Using.apply(Using.scala:28)
[error] at sbt.io.IO$.withZipOutput(IO.scala:753)
[error] at sbt.io.IO$.archive(IO.scala:673)
[error] at sbt.io.IO$.jar(IO.scala:621)
[error] at com.typesafe.sbt.osgi.Osgi$.$anonfun$bundleTask$1(Osgi.scala:187)
[error] at scala.Option.getOrElse(Option.scala:189)
[error] at com.typesafe.sbt.osgi.Osgi$.withCache(Osgi.scala:112)
[error] at com.typesafe.sbt.osgi.Osgi$.bundleTask(Osgi.scala:139)
[error] at com.typesafe.sbt.osgi.SbtOsgi$.$anonfun$defaultOsgiSettings$1(SbtOsgi.scala:57)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] at sbt.Execute.work(Execute.scala:292)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] at java.base/java.lang.Thread.run(Thread.java:829)
[error] (actor / osgiBundle) java.util.zip.ZipException: duplicate entry: META-INF/MANIFEST.MF
So, I upgraded to sbt 0.13 and sbt-osgi 0.6 on my project the other day only to discover that my project code now outputs stuff I didn't expect.
In my project, I take a bunch of project dependencies like scalatra and ice.tar, and convert them into bundles. Sometimes these dependencies have files and other non-class content embedded in them that must be copied to the resulting bundle, like with the bundle my project makes of the scala libs + akka. It used to be I could get these files with the privatePackage setting. For example, in my scala+akka bundle, I made the project depend on scala and akka, and set private packages to "*". This would pull in all the class files that were not exported, but also files like reference.conf in the root of the akka-actors jar, which is necessary for akka to work without a configuration file.
In sbt 0.6, privatePackage now only packages classes found on the classpath, not files. This is entirely an issue with aQute.bndlib being upgraded. I have a fork of this project here that downgrades aQute.bndlib and makes some minor changes to the plugin, and the behavior my project was relying on has returned. Looking at the bndlib documentation, it looks like include_resource is needed to do what I was doing, but there's no such key in sbt-osgi, and I'm not sure how exactly to do what I was doing before (package files found in the classpath into the resulting bundle).
Any idea how to fix this for the new version of bndlib and sbt-osgi?
One of the key uses os OSGI is dynamic code reloading, reloading bundles into an OSGI framework does require being able to detect when a bundle has changed. Current the plugin produces a new bundle everytime the bundle task is invoked.
I'm a novice with SBT development but I'm learning I have this question open on SO whilst trying to hack my way to some sort of a solution.
If someone could give me some pointers perhaps I can add this functionality.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.