Skip to content

published test artifacts are published as part of the compile configuration #683

@aklossrbh

Description

@aklossrbh

If you publish a test artifact using publishArtifact in Test := true, the artifact is published as part of the compile configuration like this:

<artifact name="redbrick-services-common_2.9.2" type="jar" ext="jar" conf="compile" e:classifier="test"/>

This means the test artifact is included in the compile and runtime classpath for any project depending on redbrick-services-common, so the test classes from the library can be referenced from the runtime classes of the project. This is not quite right and is very inconvenient when using sbt-assembly to build full assemblies, as the test classes from libraries are included and therefore need to be de-duplicated.

You can override this behavior by explicitly overriding the configuration in the artifact:

artifact in Test ~= { artifact => artifact.copy(configurations = List(Test)) }

If you do this, you end up with some issues related to #285. This can be mitigated by explicitly depending on the library in the test configuration:

libraryDependencies += Seq(
"com.redbrickhealth" %% "redbrick-services-common" % "1.7.721",
"com.redbrickhealth" %% "redbrick-services-common" % "1.7.721" % "test" classifier("test") classifier("")
)

This is an awful lot of configuring in SBT to get reasonable behavior of test artifacts. What do people think about changing the default test artifact to be in the test configuration and having some shorthand to eliminate the explicit declaration of the dependency for the test configuration. Something like this maybe:

libraryDependencies += Seq(
"com.redbrickhealth" %% "redbrick-services-common" % "1.7.721" withTest,
)

Thoughts?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions