question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sort out situation for managed Java sources

See original GitHub issue

The sbt documentation says:

A source generation task should generate sources in a subdirectory of sourceManaged

This works fine for generating Scala sources, but not generating Java sources. The reason is, the Java compiler needs a concept of a compilation root directory, and the one that sbt gives it for all sources in sourceManaged is sourceManaged, not sub directories of sourceManaged. Since the Java package structure must match the Java directory structure, this means in order for the Java generated source files to compile, their package structure needs to be directly under sourceManaged, not a sub directory of sourceManaged.

So this causes confusion, for example, sbt-idea follows the documentation, and treats sub directories of sourceManaged as source directories, which causes any Java files generated in sourceManaged to not compile from IntelliJ’s perspective. See https://github.com/mpeltonen/sbt-idea/pull/257. This causes a problem particularly with Play, see https://github.com/playframework/playframework/issues/2941.

One possible solution is https://github.com/sbt/sbt/issues/753, but I think the documentation should simply be updated to say something like:

A source generation task should generate sources in sourceManaged, or if it wants to keep the source files it generates separate from other source generation tasks, it should generate sources to a sub directory in crossTarget and add that directory to managedSourceDirectories.

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
eed3si9ncommented, Apr 21, 2016

The short-term workaround might be to recommend against using (sourceManaged in Compile).value altogether, and each plugin roll out their own directory under target, and append to managedSourceDirectories in Compile.

0reactions
benmccanncommented, Apr 24, 2020

The solution @eed3si9n suggested seems to work well. I finally got around to trying it in https://github.com/sbt/sbt-xjc/commit/4a0c67c7157aa04744860fe8835951c371641a80. I’ve released a new version (0.10) of sbt-xjc with the fix

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Most used Sorting Algorithms in Java (with Code) - FavTutor
Learn about the 5 most popular & most used sorting algorithms in java. These are the best sorting methods in java with time...
Read more >
Sort Control - The Java™ Tutorials
The sort control is used when a client wants the server to send the sorted search results. The server-side sorting is useful in...
Read more >
How to Sort a List in Java - DigitalOcean
Here we will learn how to sort a list of Objects in Java. We can use Collections.sort() method to sort a list in...
Read more >
Insertion Sort | Simple Sorting in Java - InformIT
The bar at outer will be copied to temp. We say that items are copied from a source to a destination. When performing...
Read more >
Java Collections Utility Examples for Changing Order and ...
Changing the order of list elements. The functions in this group allow us to reverse, rotate, permute, sort and swap elements in a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found