Scala library available in both compile and test configuration2019 Community Moderator ElectionIs the Scala 2.8 collections library a case of “the longest suicide note in history”?How do I run a scala ScalaTest in IntelliJ idea?sbteclipse: Managed dependencies not found by eclipsesbt: Add dependency on scalatest library. Where?Simple scalatest project won't be compiledAdd swf file in sbt processShould I include scala-compiler as a dependency in build.sbt?scalatest : object scalatest is not a member of package orgscala: delimited continuation issuesSBT doesn't compile tests located in custom test source folders
How are passwords stolen from companies if they only store hashes?
Why do tuner card drivers fail to build after kernel update to 4.4.0-143-generic?
How do I hide Chekhov's Gun?
"of which" is correct here?
What exactly is this small puffer fish doing and how did it manage to accomplish such a feat?
How do you talk to someone whose loved one is dying?
Math equation in non italic font
Is "upgrade" the right word to use in this context?
PTIJ: Who should I vote for? (21st Knesset Edition)
How should I state my peer review experience in the CV?
If I am holding an item before I cast Blink, will it move with me through the Ethereal Plane?
Welcoming 2019 Pi day: How to draw the letter π?
What are substitutions for coconut in curry?
Can I use USB data pins as power source
How could an airship be repaired midflight?
Why does energy conservation give me the wrong answer in this inelastic collision problem?
Why does overlay work only on the first tcolorbox?
Is a party consisting of only a bard, a cleric, and a warlock functional long-term?
combinatorics floor summation
How to pronounce "I ♥ Huckabees"?
A single argument pattern definition applies to multiple-argument patterns?
Employee lack of ownership
Instead of a Universal Basic Income program, why not implement a "Universal Basic Needs" program?
A diagram about partial derivatives of f(x,y)
Scala library available in both compile and test configuration
2019 Community Moderator ElectionIs the Scala 2.8 collections library a case of “the longest suicide note in history”?How do I run a scala ScalaTest in IntelliJ idea?sbteclipse: Managed dependencies not found by eclipsesbt: Add dependency on scalatest library. Where?Simple scalatest project won't be compiledAdd swf file in sbt processShould I include scala-compiler as a dependency in build.sbt?scalatest : object scalatest is not a member of package orgscala: delimited continuation issuesSBT doesn't compile tests located in custom test source folders
I have a library that I wish to expose in both the unit tests in Scala and the code itself.
In sbt, I added my library dependency with configuration "test"
and then it's available for tests but I cannot use it in the code. If I leave the configuration be or add "compile"
it's not available to be imported in unit tests.
libraryDependencies ++= Seq(
"org.scalacheck" %% "scalacheck" % "1.14.0",
"org.scalatest" %% "scalatest" % "3.0.6" % "test",
"org.scalactic" %% "scalactic" % "3.0.6" % "test")
The main problem is that I expose an abstract class I want to use all over the place in other code: abstract class UnitSpec extends FlatSpec with Matchers with ScalaCHeckDrivenPropertyChecks
and also use in the tests of the library. If I add "test"
to ScalaCheck it cannot find it in the main code of the library. If I leave it as is, it cannot from org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
. This used to be OK and work fine with 3.0.5 and GeneratorDrivenProperyChecks
but that's been deprecated.
Is there a way to achieve what I want? I tried "test->compile"
but that also doesn't do what I had hoped...
scala sbt
add a comment |
I have a library that I wish to expose in both the unit tests in Scala and the code itself.
In sbt, I added my library dependency with configuration "test"
and then it's available for tests but I cannot use it in the code. If I leave the configuration be or add "compile"
it's not available to be imported in unit tests.
libraryDependencies ++= Seq(
"org.scalacheck" %% "scalacheck" % "1.14.0",
"org.scalatest" %% "scalatest" % "3.0.6" % "test",
"org.scalactic" %% "scalactic" % "3.0.6" % "test")
The main problem is that I expose an abstract class I want to use all over the place in other code: abstract class UnitSpec extends FlatSpec with Matchers with ScalaCHeckDrivenPropertyChecks
and also use in the tests of the library. If I add "test"
to ScalaCheck it cannot find it in the main code of the library. If I leave it as is, it cannot from org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
. This used to be OK and work fine with 3.0.5 and GeneratorDrivenProperyChecks
but that's been deprecated.
Is there a way to achieve what I want? I tried "test->compile"
but that also doesn't do what I had hoped...
scala sbt
add a comment |
I have a library that I wish to expose in both the unit tests in Scala and the code itself.
In sbt, I added my library dependency with configuration "test"
and then it's available for tests but I cannot use it in the code. If I leave the configuration be or add "compile"
it's not available to be imported in unit tests.
libraryDependencies ++= Seq(
"org.scalacheck" %% "scalacheck" % "1.14.0",
"org.scalatest" %% "scalatest" % "3.0.6" % "test",
"org.scalactic" %% "scalactic" % "3.0.6" % "test")
The main problem is that I expose an abstract class I want to use all over the place in other code: abstract class UnitSpec extends FlatSpec with Matchers with ScalaCHeckDrivenPropertyChecks
and also use in the tests of the library. If I add "test"
to ScalaCheck it cannot find it in the main code of the library. If I leave it as is, it cannot from org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
. This used to be OK and work fine with 3.0.5 and GeneratorDrivenProperyChecks
but that's been deprecated.
Is there a way to achieve what I want? I tried "test->compile"
but that also doesn't do what I had hoped...
scala sbt
I have a library that I wish to expose in both the unit tests in Scala and the code itself.
In sbt, I added my library dependency with configuration "test"
and then it's available for tests but I cannot use it in the code. If I leave the configuration be or add "compile"
it's not available to be imported in unit tests.
libraryDependencies ++= Seq(
"org.scalacheck" %% "scalacheck" % "1.14.0",
"org.scalatest" %% "scalatest" % "3.0.6" % "test",
"org.scalactic" %% "scalactic" % "3.0.6" % "test")
The main problem is that I expose an abstract class I want to use all over the place in other code: abstract class UnitSpec extends FlatSpec with Matchers with ScalaCHeckDrivenPropertyChecks
and also use in the tests of the library. If I add "test"
to ScalaCheck it cannot find it in the main code of the library. If I leave it as is, it cannot from org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
. This used to be OK and work fine with 3.0.5 and GeneratorDrivenProperyChecks
but that's been deprecated.
Is there a way to achieve what I want? I tried "test->compile"
but that also doesn't do what I had hoped...
scala sbt
scala sbt
edited Mar 7 at 15:41
Max Power
asked Mar 7 at 15:27
Max PowerMax Power
18911
18911
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can combine configurations. In order to have a library both in compile and test you just add bot configurations.
// wrong: libraryDependencies += "<organization>" %% "<module>" % "<version>" % "compile->compile" % "test->compile"
The syntax means roughly: project configuration dependsOn(->) configuration of libraryDependency.
Update
You can also add the dependency twice with different configurations.
libraryDependencies += "<organization>" %% "<module>" % "<version>",
libraryDependencies += "<organization>" %% "<module>" % "<version>" % "test"
Update 2
I think the syntax in the first example is not what I meant to provide.
libraryDependencies += "<organization>" %% "<module>" % "<version>" % "compile->compile;test->compile"
At least that is what I use in my libraryDependencies
.
When I do that I getConfigurations already specified for module org.scalacheck:scalacheck:1.14.0:compile->compile
. I also tried% "compile" % "test"
but that gives me the same.
– Max Power
Mar 8 at 8:31
What does remote/local configuration mean in this context? I managed to get it working with a simple"compile;test"
for the libraries that need to be in both. It did not work with the arrows.
– Max Power
Mar 13 at 8:03
1
I updated the answer with (hopefully) clearer wording. Imo the expanded syntaxcompile->compile
is more expressive. However, you are right, one only really needs it if something more exotic is needed (e.g. if there are non standard configurations involved or someone would want to havecompile
depend on test code of a dependency 'compile->test' (weird, but happens).
– Sascha Kolberg
Mar 13 at 9:35
add a comment |
So you need a trait from the Scalatest JAR in non-test code. I am not sure why it worked before, but it would make sense to me just to remove % "test"
from the scalatest dependency. That will make it available in compile
and everything from compile
is available in test
too.
And for Scalactic I think the main use-case for it as a separate dependency is when you need it in compile
but only use Scalatest in test
(or don't use it at all). If they are both needed for tests only (or for compile), Scalatest will bring Scalactic with it.
I tried "test->compile" but that also doesn't do what I had hoped...
"test->compile"
is the same as "test"
:
A configuration without a mapping (no
"->"
) is mapped to"default"
or"compile"
. The->
is only needed when mapping to a different configuration than those.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047355%2fscala-library-available-in-both-compile-and-test-configuration%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can combine configurations. In order to have a library both in compile and test you just add bot configurations.
// wrong: libraryDependencies += "<organization>" %% "<module>" % "<version>" % "compile->compile" % "test->compile"
The syntax means roughly: project configuration dependsOn(->) configuration of libraryDependency.
Update
You can also add the dependency twice with different configurations.
libraryDependencies += "<organization>" %% "<module>" % "<version>",
libraryDependencies += "<organization>" %% "<module>" % "<version>" % "test"
Update 2
I think the syntax in the first example is not what I meant to provide.
libraryDependencies += "<organization>" %% "<module>" % "<version>" % "compile->compile;test->compile"
At least that is what I use in my libraryDependencies
.
When I do that I getConfigurations already specified for module org.scalacheck:scalacheck:1.14.0:compile->compile
. I also tried% "compile" % "test"
but that gives me the same.
– Max Power
Mar 8 at 8:31
What does remote/local configuration mean in this context? I managed to get it working with a simple"compile;test"
for the libraries that need to be in both. It did not work with the arrows.
– Max Power
Mar 13 at 8:03
1
I updated the answer with (hopefully) clearer wording. Imo the expanded syntaxcompile->compile
is more expressive. However, you are right, one only really needs it if something more exotic is needed (e.g. if there are non standard configurations involved or someone would want to havecompile
depend on test code of a dependency 'compile->test' (weird, but happens).
– Sascha Kolberg
Mar 13 at 9:35
add a comment |
You can combine configurations. In order to have a library both in compile and test you just add bot configurations.
// wrong: libraryDependencies += "<organization>" %% "<module>" % "<version>" % "compile->compile" % "test->compile"
The syntax means roughly: project configuration dependsOn(->) configuration of libraryDependency.
Update
You can also add the dependency twice with different configurations.
libraryDependencies += "<organization>" %% "<module>" % "<version>",
libraryDependencies += "<organization>" %% "<module>" % "<version>" % "test"
Update 2
I think the syntax in the first example is not what I meant to provide.
libraryDependencies += "<organization>" %% "<module>" % "<version>" % "compile->compile;test->compile"
At least that is what I use in my libraryDependencies
.
When I do that I getConfigurations already specified for module org.scalacheck:scalacheck:1.14.0:compile->compile
. I also tried% "compile" % "test"
but that gives me the same.
– Max Power
Mar 8 at 8:31
What does remote/local configuration mean in this context? I managed to get it working with a simple"compile;test"
for the libraries that need to be in both. It did not work with the arrows.
– Max Power
Mar 13 at 8:03
1
I updated the answer with (hopefully) clearer wording. Imo the expanded syntaxcompile->compile
is more expressive. However, you are right, one only really needs it if something more exotic is needed (e.g. if there are non standard configurations involved or someone would want to havecompile
depend on test code of a dependency 'compile->test' (weird, but happens).
– Sascha Kolberg
Mar 13 at 9:35
add a comment |
You can combine configurations. In order to have a library both in compile and test you just add bot configurations.
// wrong: libraryDependencies += "<organization>" %% "<module>" % "<version>" % "compile->compile" % "test->compile"
The syntax means roughly: project configuration dependsOn(->) configuration of libraryDependency.
Update
You can also add the dependency twice with different configurations.
libraryDependencies += "<organization>" %% "<module>" % "<version>",
libraryDependencies += "<organization>" %% "<module>" % "<version>" % "test"
Update 2
I think the syntax in the first example is not what I meant to provide.
libraryDependencies += "<organization>" %% "<module>" % "<version>" % "compile->compile;test->compile"
At least that is what I use in my libraryDependencies
.
You can combine configurations. In order to have a library both in compile and test you just add bot configurations.
// wrong: libraryDependencies += "<organization>" %% "<module>" % "<version>" % "compile->compile" % "test->compile"
The syntax means roughly: project configuration dependsOn(->) configuration of libraryDependency.
Update
You can also add the dependency twice with different configurations.
libraryDependencies += "<organization>" %% "<module>" % "<version>",
libraryDependencies += "<organization>" %% "<module>" % "<version>" % "test"
Update 2
I think the syntax in the first example is not what I meant to provide.
libraryDependencies += "<organization>" %% "<module>" % "<version>" % "compile->compile;test->compile"
At least that is what I use in my libraryDependencies
.
edited Mar 13 at 9:32
answered Mar 7 at 18:24
Sascha KolbergSascha Kolberg
5,89112534
5,89112534
When I do that I getConfigurations already specified for module org.scalacheck:scalacheck:1.14.0:compile->compile
. I also tried% "compile" % "test"
but that gives me the same.
– Max Power
Mar 8 at 8:31
What does remote/local configuration mean in this context? I managed to get it working with a simple"compile;test"
for the libraries that need to be in both. It did not work with the arrows.
– Max Power
Mar 13 at 8:03
1
I updated the answer with (hopefully) clearer wording. Imo the expanded syntaxcompile->compile
is more expressive. However, you are right, one only really needs it if something more exotic is needed (e.g. if there are non standard configurations involved or someone would want to havecompile
depend on test code of a dependency 'compile->test' (weird, but happens).
– Sascha Kolberg
Mar 13 at 9:35
add a comment |
When I do that I getConfigurations already specified for module org.scalacheck:scalacheck:1.14.0:compile->compile
. I also tried% "compile" % "test"
but that gives me the same.
– Max Power
Mar 8 at 8:31
What does remote/local configuration mean in this context? I managed to get it working with a simple"compile;test"
for the libraries that need to be in both. It did not work with the arrows.
– Max Power
Mar 13 at 8:03
1
I updated the answer with (hopefully) clearer wording. Imo the expanded syntaxcompile->compile
is more expressive. However, you are right, one only really needs it if something more exotic is needed (e.g. if there are non standard configurations involved or someone would want to havecompile
depend on test code of a dependency 'compile->test' (weird, but happens).
– Sascha Kolberg
Mar 13 at 9:35
When I do that I get
Configurations already specified for module org.scalacheck:scalacheck:1.14.0:compile->compile
. I also tried % "compile" % "test"
but that gives me the same.– Max Power
Mar 8 at 8:31
When I do that I get
Configurations already specified for module org.scalacheck:scalacheck:1.14.0:compile->compile
. I also tried % "compile" % "test"
but that gives me the same.– Max Power
Mar 8 at 8:31
What does remote/local configuration mean in this context? I managed to get it working with a simple
"compile;test"
for the libraries that need to be in both. It did not work with the arrows.– Max Power
Mar 13 at 8:03
What does remote/local configuration mean in this context? I managed to get it working with a simple
"compile;test"
for the libraries that need to be in both. It did not work with the arrows.– Max Power
Mar 13 at 8:03
1
1
I updated the answer with (hopefully) clearer wording. Imo the expanded syntax
compile->compile
is more expressive. However, you are right, one only really needs it if something more exotic is needed (e.g. if there are non standard configurations involved or someone would want to have compile
depend on test code of a dependency 'compile->test' (weird, but happens).– Sascha Kolberg
Mar 13 at 9:35
I updated the answer with (hopefully) clearer wording. Imo the expanded syntax
compile->compile
is more expressive. However, you are right, one only really needs it if something more exotic is needed (e.g. if there are non standard configurations involved or someone would want to have compile
depend on test code of a dependency 'compile->test' (weird, but happens).– Sascha Kolberg
Mar 13 at 9:35
add a comment |
So you need a trait from the Scalatest JAR in non-test code. I am not sure why it worked before, but it would make sense to me just to remove % "test"
from the scalatest dependency. That will make it available in compile
and everything from compile
is available in test
too.
And for Scalactic I think the main use-case for it as a separate dependency is when you need it in compile
but only use Scalatest in test
(or don't use it at all). If they are both needed for tests only (or for compile), Scalatest will bring Scalactic with it.
I tried "test->compile" but that also doesn't do what I had hoped...
"test->compile"
is the same as "test"
:
A configuration without a mapping (no
"->"
) is mapped to"default"
or"compile"
. The->
is only needed when mapping to a different configuration than those.
add a comment |
So you need a trait from the Scalatest JAR in non-test code. I am not sure why it worked before, but it would make sense to me just to remove % "test"
from the scalatest dependency. That will make it available in compile
and everything from compile
is available in test
too.
And for Scalactic I think the main use-case for it as a separate dependency is when you need it in compile
but only use Scalatest in test
(or don't use it at all). If they are both needed for tests only (or for compile), Scalatest will bring Scalactic with it.
I tried "test->compile" but that also doesn't do what I had hoped...
"test->compile"
is the same as "test"
:
A configuration without a mapping (no
"->"
) is mapped to"default"
or"compile"
. The->
is only needed when mapping to a different configuration than those.
add a comment |
So you need a trait from the Scalatest JAR in non-test code. I am not sure why it worked before, but it would make sense to me just to remove % "test"
from the scalatest dependency. That will make it available in compile
and everything from compile
is available in test
too.
And for Scalactic I think the main use-case for it as a separate dependency is when you need it in compile
but only use Scalatest in test
(or don't use it at all). If they are both needed for tests only (or for compile), Scalatest will bring Scalactic with it.
I tried "test->compile" but that also doesn't do what I had hoped...
"test->compile"
is the same as "test"
:
A configuration without a mapping (no
"->"
) is mapped to"default"
or"compile"
. The->
is only needed when mapping to a different configuration than those.
So you need a trait from the Scalatest JAR in non-test code. I am not sure why it worked before, but it would make sense to me just to remove % "test"
from the scalatest dependency. That will make it available in compile
and everything from compile
is available in test
too.
And for Scalactic I think the main use-case for it as a separate dependency is when you need it in compile
but only use Scalatest in test
(or don't use it at all). If they are both needed for tests only (or for compile), Scalatest will bring Scalactic with it.
I tried "test->compile" but that also doesn't do what I had hoped...
"test->compile"
is the same as "test"
:
A configuration without a mapping (no
"->"
) is mapped to"default"
or"compile"
. The->
is only needed when mapping to a different configuration than those.
edited Mar 13 at 11:52
answered Mar 13 at 11:39
Alexey RomanovAlexey Romanov
109k26215356
109k26215356
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047355%2fscala-library-available-in-both-compile-and-test-configuration%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown