sbt-idea icon indicating copy to clipboard operation
sbt-idea copied to clipboard

Support configuable source/javadoc classifiers

Open jonfreedman opened this issue 13 years ago • 14 comments

Our internal repository uses the classifier src rather than sources, and as per Ivy's documentation this may not be that unusual

As per our discussion on the sbt mailing list, it would be useful to be able to configure a Seq of classifiers rather than hardcoding "sources" & "javadoc"

jonfreedman avatar Sep 30 '11 08:09 jonfreedman

Note that having a sequence of classifiers doesn't help. That already exists in SBT and is called transitiveClassifiers. What we want is a way to map from that sequence of classifiers into the two types that IDEA supports: source and javadoc.

Two settings should do the job, I think.

ijuma avatar Sep 30 '11 09:09 ijuma

So do you mean something like:

set transitiveClassifiers := Seq("src", "sources", "javadocs") set ideaSourcesClassifiers := Seq("src", "sources") set ideaJavadocsClassifiers := Seq("javadocs")

mpeltonen avatar Sep 30 '11 12:09 mpeltonen

Yes exactly

jonfreedman avatar Sep 30 '11 13:09 jonfreedman

Looks good to me too.

ijuma avatar Sep 30 '11 13:09 ijuma

You could test this now with 0.11.1-SNAPSHOT, i.e. put something like this in build.sbt:

transitiveClassifiers += "src"

ideaSourcesClassifiers += "src"

and report back whether it works for you or not (I tested just very briefly so...).

mpeltonen avatar Oct 01 '11 20:10 mpeltonen

Could you build for scala 2.8.1

jonfreedman avatar Oct 04 '11 22:10 jonfreedman

To my understanding, sbt 0.11 does not support scala 2.8 for build definition/plugins, or am I wrong? At least I can't easily compile with just setting crossScalaVersions because sbt_2.8.1 -stuff is not found from repos.

Is there something preventing you from using 2.9 (you can use 2.8 for your project code, of course)?

mpeltonen avatar Oct 05 '11 03:10 mpeltonen

That is correct. SBT 0.10 is the only version that used Scala 2.8 for plugins and build definition.

ijuma avatar Oct 05 '11 07:10 ijuma

I've upgraded to sbt 0.11.0 - it appears that when I run gen-idea for dependencies I've had to declare the artifacts manually the src dependency ends up being copied into the jar type in my local Ivy repository. For example:

dependency: "x" % "y" % "8.2.2" % "compile" artifacts (Artifact("y"), Artifact("y", "src", "jar", "src")),

ivy cache (before running gen-idea): ....ivy2\cache\x\y\jars\y-8.2.2.jar ....ivy2\cache\x\y\srcs\y-8.2.2-src.jar

additional file after running gen-idea: ....ivy2\cache\x\y\jars\y-8.2.2-src.jar

In addition the src jars for standard dependencies declared without specifying their artifacts are still being added as CLASSES rather than SOURCES in libraries*.xml

I'm using the full configuration for project\MyProject.scala and the simple configuration for project\plugins\build.sbt with the following in MyProject.scala - is this in the correct place?

def c2settings: Seq[Setting[_]] = Defaults.defaultSettings ++ Seq( [...snip...] transitiveClassifiers := Seq("src"), SbtIdeaPlugin.ideaSourcesClassifiers += "src", SbtIdeaPlugin.ideaJavadocsClassifiers += "doc", [...snip...] )

lazy val project = Project("project", file("."), settings = c2settings)

jonfreedman avatar Oct 06 '11 15:10 jonfreedman

I noticed too that -src gets placed into jars -dir instead of srcs -dir, which I think should not be a problem as such, but this "are still being added as CLASSES rather than SOURCES in libraries*.xml" needs some investigation. Thanks for the report.

mpeltonen avatar Oct 07 '11 06:10 mpeltonen

Is there any way to simply turn off looking for src and javadoc classifiers? I'm on a coffee shop wireless network and this is taking a while.

[error] Server access Error: Operation timed out url=http://repo1.maven.org/maven2/org/springframework/spring-jdbc/3.0.4.RELEASE/spring-jdbc-3.0.4.RELEASE-javadoc.jar [warn] [NOT FOUND ] org.springframework#spring-jdbc;3.0.4.RELEASE!spring-jdbc.jar(doc) (77031ms) [warn] ==== public: tried [warn] http://repo1.maven.org/maven2/org/springframework/spring-jdbc/3.0.4.RELEASE/spring-jdbc-3.0.4.RELEASE-javadoc.jar [error] Server access Error: Operation timed out url=http://repo1.maven.org/maven2/org/springframework/spring-beans/3.0.4.RELEASE/spring-beans-3.0.4.RELEASE-javadoc.jar [warn] [NOT FOUND ] org.springframework#spring-beans;3.0.4.RELEASE!spring-beans.jar(doc) (76486ms)

wsargent avatar Oct 30 '11 02:10 wsargent

'gen-idea no-classifiers no-sbt-classifiers' should do the trick. But no permanently configurable way to turn it off.

mpeltonen avatar Oct 30 '11 05:10 mpeltonen

Ahh this is very helpful for the exact reasons wsargent mentioned. Thank you mpeltonen.

digicyc avatar Oct 30 '11 17:10 digicyc

The change (4f7acd829eb4b330ae263404dd56c8fb27b85993) introduced to deal with this problem has broken generation of sources for the sbt-and-plugins library in .idea_modules/project.iml. Any clues what happened here?

jrudolph avatar Nov 28 '11 10:11 jrudolph