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.

Scaladoc not picking up generated sources

See original GitHub issue

I did some investigating and found that scaladoc is not picking up the generated sources directories when run by itself. If I ran “mvn compile scala:doc” the documents would get produced correctly. If I ran “mvn generate-sources scada:doc” it would work. Running just “mvn scala:doc” would fail because it wasn’t seeing the list of generated sources even though that phase was being executed.

The problem is the way generate-sources gets run: “@execute phase=“generate-sources””. According to the documentation at: http://maven.apache.org/developers/mojo-api-specification.html, using the @execute annotation spawns a “sub maven” that has a different project object (i verified this manually). So the source generators all correctly add their generated directories to the project object they are given but this is not the same as the one used by scala-doc. The result of that project are available as a different parameter.

/**
 * @parameter expression="${executedProject}"
 * @required
 * @readonly
 */
protected MavenProject executedProject;

I found that in my case if i then used the executedProject reference rather than the regular project in getSourceDirectories I was able to generate scala:doc using just the one command. I am not a maven expert (though I know alot more than I did yesterday) so I wasn’t sure the reprocusions of the other executedProject and how the results should be merged together or which reference should be used for which call. I’m not sure what the right solution is but I don’t think this is doing what you expected.

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
muhukcommented, Apr 25, 2016

I have Java interfaces and a Scala class extending them in the same package (in their respective source dirs of course). I get no found errors on the interfaces even when I run only compile.

Using Scala 2.11.8 and Java 1.8 as target. My POM looks very much like @jvstein’s. Funny thing is Eclipse seems to compile just fine.


EDIT Sorry for the noise. I fixed my problem, leaving this if anyone else bumps into the same problem:

In maven console, with debug enabled, I saw this:

[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile' with basic configurator -->
[DEBUG]   (f) basedir = /home/muhuk/Documents/workspace/project-name
[DEBUG]   (f) buildDirectory = /home/muhuk/Documents/workspace/project-name/target
[DEBUG]   (f) classpathElements = [/home/muhuk/Documents/workspace/project-name/target/classes, /home/muhuk/.m2/repository/org/scala-lang/scala-library/2.11.8/scala-library-2.11.8.jar, /home/muhuk/.m2/repository/org/scala-lang/scala-reflect/2.11.8/scala-reflect-2.11.8.jar, /home/muhuk/.m2/repository/org/scala-lang/modules/scala-parser-combinators_2.11/1.0.4/scala-parser-combinators_2.11-1.0.4.jar]
[DEBUG]   (f) compileSourceRoots = [/home/muhuk/Documents/workspace/project-name/src/main/scala]
[DEBUG]   (f) compilerId = javac
[DEBUG]   (f) debug = true
[DEBUG]   (f) failOnError = true
[DEBUG]   (f) fork = false
[DEBUG]   (f) optimize = false
[DEBUG]   (f) outputDirectory = /home/muhuk/Documents/workspace/project-name/target/classes
[DEBUG]   (f) outputFileName = project-name-0.0.1-SNAPSHOT
[DEBUG]   (f) projectArtifact = prj:project-name:jar:0.0.1-SNAPSHOT
[DEBUG]   (f) showDeprecation = false
[DEBUG]   (f) showWarnings = false
[DEBUG]   (f) source = 1.8
[DEBUG]   (f) staleMillis = 0
[DEBUG]   (f) target = 1.8
[DEBUG]   (f) verbose = false
[DEBUG] -- end configuration --

src/main/java wasn’t getting picked up by maven-compiler-plugin as a source dir. After much flitting and flapping and rolling around on the floor I managed to make maven gods happy doing:

  1. Remove <build><sourceDirectory>... & <build><testSourceDirectory>....
  2. Add <goal>add-source</goal> to scala-maven-plugin. Like so:
    <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <executions>
            <execution>
                <goals>
                    <goal>add-source</goal>
                    <goal>compile</goal>
                    <goal>testCompile</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
0reactions
slandellecommented, Jun 17, 2022

Closing as stale.

Read more comments on GitHub >

github_iconTop Results From Across the Web

scala - Linking to sources from scaladoc? - Stack Overflow
I need to link to sources on github from my scaladoc. I build those docs with the sbt's doc task. There are two...
Read more >
How to generate Scala documentation with the 'scaladoc ...
To generate Scaladoc API documentation, document your code using ... You can mark up your source code using Scaladoc tags as well as...
Read more >
sbt Reference Manual — Generate API documentation
Generate API documentation. Select javadoc or scaladoc. sbt will run javadoc if there are only Java sources in the project. If there are...
Read more >
Scaladoc | Style Guide | Scala Documentation
The Scaladoc tool does not mandate a documentation comment style. ... Since Scala source is usually indented by two spaces, the text aligns...
Read more >
How do I add source links in my scaladoc?
produce Scaladoc output that includes a link to sources? ... just working on 0.1x now. ... Where are the scaladoc html file generated...
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