Be careful in your testing: javadoc:javadoc forks a lifecycle at 'generate-sources' phase (and javadoc:aggregate at 'compile' phase), whereas javadoc:jar does not! So running 'mvn javadoc:jar' alone indeed won't run your protoc plugin, which won't add the generated sources as a compile source root. Running 'mvn generate-sources javadoc:jar' would work differently; and obviously binding javadoc:jar to a phase in your build (after generate-sources phase, default being 'package') and running 'mvn package' should then work the same.
Le mar. 13 mars 2018 18:57, Laird Nelson <ljnel...@gmail.com> a écrit : > I am finding that the sourcepath for javadoc:jar (when run as part of the > release profile) is different from the sourcepath for javadoc:javadoc in my > project that involves (protoc-) generated sources. > > (The net effect is that at release time, everything works fine up until > release:perform, which fails (!) during the attach-javadocs execution I've > configured following the documentation ( > > https://maven.apache.org/plugin-developers/cookbook/attach-source-javadoc-artifacts.html#Configuring_Maven_Javadoc_Plugin > ) > ). > > I have a <pluginManagement> stanza centralizing my maven-javadoc-plugin > configuration that does not mention sourcepath in any way. > > mvn help:effective-pom -Prelease shows exactly what I would expect, and no > additional maven-javadoc-plugin configuration. > > Somehow, the sourcepath for javadoc:javadoc has the generated-sources > directory in it; the sourcepath for javadoc:jar does not. > > Here is the pluginManagement section (it's quite ordinary): > > <plugin> > <artifactId>maven-javadoc-plugin</artifactId> > <version>3.0.0-M1</version> > <configuration> > <doclint>-missing</doclint> > </configuration> > </plugin> > > When I run mvn -X javadoc:javadoc and inspect the options file, I see this: > > -sourcepath > '/Users/ljnelson/Projects/frob/src/main/java: > > */Users/ljnelson/Projects/frob/target/generated-sources/protobuf/java:/Users/ljnelson/Projects/frob/target/generated-sources/protobuf/grpc-java* > :/Users/ljnelson/Projects/frob/src/main/javadoc' > > When I run mvn -X javadoc:jar and inspect the options file, I see only > this: > > -sourcepath > > '/Users/ljnelson/Projects/frob/src/main/java:/Users/ljnelson/Projects/frob/src/main/javadoc' > > The javadoc:jar goal outputs a bunch of warnings. When I run it locally > (mvn javadoc:jar), they show up as warnings. When it is run as part of the > maven-release-plugin's perform goal, it fails the build. > > I'm at a loss as to how to go about fixing this. Is it, perhaps, the job > of the plugin in charge of generating the sources to do something here? > > Best, > Laird >