Closed cielo closed 5 years ago
Hi,
Are you missing compile-custom
in the list of goals in the POM? Maybe the IDE does not read it from the POM and does not know that you have an additional output. I suggest adding compile-custom
as a separate execution and removing the outputDirectory
override, then everything will hopefully be resolved correctly. If that does not work, then it may be a problem with the IDE, in which case you may want to raise an issue with the IDE developers instead.
Try this:
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.7.1:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.21.0:exe:${os.detected.classifier}</pluginArtifact>
<clearOutputDirectory>false</clearOutputDirectory>
</configuration>
<executions>
<execution>
<id>protobuf-compile</id>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
<execution>
<id>protobuf-compile-custom</id>
<goals>
<goal>compile-custom</goal>
<goal>test-compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
Hello,
Thanks for the reply. Your suggestion solved my problem!
I somehow have been mis-reading test-compile
goal in my old version of pom.xml as compile-custom
until I saw your response. duh...
After following your approach, everything is working as expected now. Honestly, I am not sure how test-compile
ended up in there, as example in grpc-java doc has compile-custom
, and not a single line of test-compile
Also, I guess I will have to study maven little bit more.. as I had not known that having goals explicitly listed in execution allows output directory to be added to the class path. (is it true?)
Thank you so much!
Hi,
I am glad your issue has been resolved. I still recommend configuring separate executions for compile
and compile-custom
, even if you drop the "test" goals.
If you do not list all goals in the POM, the IDE will have no knowledge of the actual configuration. IntelliJ IDEA, for example, runs generate-sources
lifecycle goal against the POM to figure out the directories with generated sources. I reckon that VCS2 may be doing the same thing.
Describe the bug I am using
compile
goal to generate main java source files, as well ascompile-custom
goal to run 'grpc-java' plugin to generate 'grpc-java' source files.The goal 'compile' generates files in
target/generated-sources/protobuf/java
while the goal 'compile-custom' generates files in
target/generated-sources/protobuf/grpc-java
This seems to be the correct behavior as defined in the document and I am fine with this part.
The problem that I am facing is... While my IDE correctly adds generated source files of
compile
goal to classpath, it does not add generated source files ofcompile-custom
to the classpath. When I inspect.classpath
file in the root directory, I am only seeingtarget/generated-sources/protobuf/java
but not the one withtarget/generated-sources/protobuf/grpc-java
.The workaround method that I am using is to force all source files (from
compile
&compile-custom
) to be generated in a predefined directory usingoutputDirectory
&clearOutputDirectory
configurations.While this works, I have to explicitly define
/target/generated-sources/protobuf/java/...
and I want to avoid it. I would rather rely on default behavior, if the default behavior can correctly adds result of `compile-custom' to classpaths.Is this an expected behavior?
Environment
Standalone or IDE Are you are running Maven inside an IDE, and in that case, which IDE? Yes, I am using Maven inside IDE. Visual Code Studio 2
Plugin configuration
To Reproduce Steps to reproduce the behavior:
compile
&compile-custom
goals in Visual Code Studio 2.Expected behavior Just like how result directory of
compile
goal gets added to the classpath, I want the result directory ofcompile-custom
goal to be added to the class path as well by default without any configuration changes.