Comments (8)
I have the same issue with a plain java project. 0.8.19 generates code, but 0.9.4 doesn't. I haven't spotted the difference yet. 0.8.19 throws a lot of deprecation warnings in gradle 8.x and gradle fails to build sourcesJar, so I was trying to update the plugin.
from protobuf-gradle-plugin.
You say you tried 0.9.0. Did you not try 0.9.4? It was released 9 months ago.
It works fine for me if I remove this:
// DELETE THIS
sourceSets {
main {
java {
srcDirs += file("${protobuf.generatedFilesBaseDir}/main/javalite")
}
}
}
That modifies the sourceSet without any dependency information, so that probably only happened to work before. The plugin adds the generated sources to the Java sourceset, so that shouldn't have been needed even with 0.8.x.
from protobuf-gradle-plugin.
In my case, the gradle file looks like this (excerpt from a multiproject build):
plugins {
id 'java-project-plugin'
id 'com.google.protobuf' version '0.9.4'
}
ext {
protoGenDir = "${project.buildDir}/src/proto"
}
sourceSets {
main {
proto {
// The folder with the proto files
srcDir "${project.projectDir}/src/main/resources/proto"
}
// seems this is only needed for Eclipse to recognize those generated source folders
java {
srcDir "${project.ext.protoGenDir}/main/grpc"
srcDir "${project.ext.protoGenDir}/main/java"
}
// end of eclipse source folder stuff
}
}
dependencies {
implementation group: 'io.grpc', name: 'grpc-netty-shaded', version: '1.57.1'
implementation group: 'io.grpc', name: 'grpc-protobuf', version: '1.57.1'
implementation group: 'io.grpc', name: 'grpc-stub', version: '1.57.1'
testImplementation group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.9'
testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.9'
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.23.4'
}
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.57.1'
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
}
generatedFilesBaseDir = project.ext.protoGenDir
}
With 0.9.4 and gradle 8.6 it generates nothing, the build folders stay empty, even the extracted-include-protos dir is empty, and the java compile fails because no generated sources. Only build/resources/main/proto is filled with the copied proto files. And the tasks are "UP-TO-DATE" or have "NO-SOURCE"
> Task :terminalmgmtinterface:extractGenProto UP-TO-DATE
Caching disabled for task ':terminalmgmtinterface:extractGenProto' because:
Build cache is disabled
Skipping task ':terminalmgmtinterface:extractGenProto' as it is up-to-date.
Resolve mutations for :terminalmgmtinterface:extractIncludeGenProto (Thread[Execution worker,5,main]) started.
:terminalmgmtinterface:extractIncludeGenProto (Thread[Execution worker,5,main]) started.
> Task :terminalmgmtinterface:extractIncludeGenProto UP-TO-DATE
Caching disabled for task ':terminalmgmtinterface:extractIncludeGenProto' because:
Build cache is disabled
Skipping task ':terminalmgmtinterface:extractIncludeGenProto' as it is up-to-date.
Resolve mutations for :terminalmgmtinterface:generateGenProto (Thread[Execution worker,5,main]) started.
:terminalmgmtinterface:generateGenProto (Thread[Execution worker,5,main]) started.
> Task :terminalmgmtinterface:generateGenProto NO-SOURCE
Deleting stale output file: D:\projects\Gitrepos\server\terminalmgmtinterface\build\generated\source\proto\gen
Skipping task ':terminalmgmtinterface:generateGenProto' as it has no source files and no previous output files.
Resolve mutations for :terminalmgmtinterface:generateSources (Thread[Execution worker,5,main]) started.
:terminalmgmtinterface:generateSources (Thread[Execution worker,5,main]) started.
> Task :terminalmgmtinterface:generateSources SKIPPED
Skipping task ':terminalmgmtinterface:generateSources' as task onlyIf 'Task is enabled' is false.
Resolve mutations for :terminalmgmtinterface:compileGenJava (Thread[Execution worker,5,main]) started.
:terminalmgmtinterface:compileGenJava (Thread[Execution worker,5,main]) started.
> Task :terminalmgmtinterface:compileGenJava NO-SOURCE
Skipping task ':terminalmgmtinterface:compileGenJava' as it has no source files and no previous output files.
Resolve mutations for :terminalmgmtinterface:processGenResources (Thread[Execution worker,5,main]) started.
:terminalmgmtinterface:processGenResources (Thread[Execution worker,5,main]) started.
> Task :terminalmgmtinterface:processGenResources NO-SOURCE
Skipping task ':terminalmgmtinterface:processGenResources' as it has no source files and no previous output files.
Resolve mutations for :terminalmgmtinterface:genClasses (Thread[Execution worker,5,main]) started.
:terminalmgmtinterface:genClasses (Thread[Execution worker,5,main]) started.
> Task :terminalmgmtinterface:genClasses UP-TO-DATE
Skipping task ':terminalmgmtinterface:genClasses' as it has no actions.
Resolve mutations for :terminalmgmtinterface:extractProto (Thread[Execution worker,5,main]) started.
:terminalmgmtinterface:extractProto (Thread[Execution worker,5,main]) started.
> Task :terminalmgmtinterface:extractProto UP-TO-DATE
Caching disabled for task ':terminalmgmtinterface:extractProto' because:
Build cache is disabled
Skipping task ':terminalmgmtinterface:extractProto' as it is up-to-date.
Resolve mutations for :terminalmgmtinterface:generateProperties (Thread[Execution worker,5,main]) started.
:terminalmgmtinterface:generateProperties (Thread[Execution worker,5,main]) started.
> Task :terminalmgmtinterface:generateProperties SKIPPED
Skipping task ':terminalmgmtinterface:generateProperties' as task onlyIf 'Task is enabled' is false.
Resolve mutations for :terminalmgmtinterface:processResources (Thread[Execution worker,5,main]) started.
:terminalmgmtinterface:processResources (Thread[Execution worker,5,main]) started.
> Task :terminalmgmtinterface:processResources UP-TO-DATE
Caching disabled for task ':terminalmgmtinterface:processResources' because:
Build cache is disabled
Skipping task ':terminalmgmtinterface:processResources' as it is up-to-date.
Resolve mutations for :terminalmgmtinterface:checkSecuredTextSignatures (Thread[Execution worker,5,main]) started.
:terminalmgmtinterface:checkSecuredTextSignatures (Thread[Execution worker,5,main]) started.
> Task :terminalmgmtinterface:checkSecuredTextSignatures SKIPPED
Skipping task ':terminalmgmtinterface:checkSecuredTextSignatures' as task onlyIf 'Task is enabled' is false.
Resolve mutations for :terminalmgmtinterface:generateJsonSchema2Pojo (Thread[Execution worker,5,main]) started.
:terminalmgmtinterface:generateJsonSchema2Pojo (Thread[Execution worker,5,main]) started.
> Task :terminalmgmtinterface:generateJsonSchema2Pojo SKIPPED
Skipping task ':terminalmgmtinterface:generateJsonSchema2Pojo' as task onlyIf 'Task is enabled' is false.
Resolve mutations for :terminalmgmtinterface:compileJava (Thread[Execution worker,5,main]) started.
:terminalmgmtinterface:compileJava (Thread[Execution worker,5,main]) started.
> Task :terminalmgmtinterface:compileJava
Caching disabled for task ':terminalmgmtinterface:compileJava' because:
Build cache is disabled
Task ':terminalmgmtinterface:compileJava' is not up-to-date because:
Task has failed previously.
The input changes require a full rebuild for incremental task ':terminalmgmtinterface:compileJava'.
Full recompilation is required because no incremental change information is available. This is usually caused by clean builds or changing compiler arguments.
Compiling with toolchain 'C:\compiler\jdk-11.0.20.1+1'.
from protobuf-gradle-plugin.
@dl6lr, remove the protoGenDir
goo and apply the idea
or eclipse
plugins. The issue with IDEs is the folders have to exist already, and applying those plugins triggers workaround code in protobuf-gradle-plugin to create the folders eagerly.
from protobuf-gradle-plugin.
@ejona86 Thanks for your suggestion. I just tested it with no different results: No proto files are processed, no java files are generated. I changed the script to:
// AC-2799 seems this is only needed for Eclipse to recognize those source folders
//java {
//srcDir "${project.ext.protoGenDir}/main/grpc"
//srcDir "${project.ext.protoGenDir}/main/java"
//}
// AC-2799 end of eclipse source folder stuff
The eclipse plugin is already applied.
from protobuf-gradle-plugin.
@dl6lr, seems your issue is different. Please open a separate issue (you can link to your initial comment here).
from protobuf-gradle-plugin.
@ejona86 thanks for your time. My issue seems to be caused by a (complex) multi project setup. I thought it is related.
from protobuf-gradle-plugin.
I have a similar problem: When I remove the java.srcDirs += ...
part the proto-files are compiled and java/kotlin code is generated. The thing is, we also use another code generator which is not related to protobuf. It's generated sources still have to be added to java.srcDirs
. But as soon as any entry is added to java.srcDirs
protobuf refuses to compile the *.proto
files.
(using com.google.protobuf:protobuf-gradle-plugin:0.9.4
)
from protobuf-gradle-plugin.
Related Issues (20)
- Task generateProto is not executed before task compileJava during build in version 0.9.3 HOT 7
- How to avoid package proto files into apk HOT 1
- Unable to use lite version - multiple versions of class HOT 31
- How config proto src dir when proto files import by path HOT 2
- Java keyword "public" not escaped during proto generation HOT 1
- doc improvement HOT 1
- How can I disable registering the generated Java code as sources? HOT 7
- KSP dependency on generateProto - unable to build project due to KspTaskJvm issue HOT 1
- Fail on protoc warnings HOT 1
- Feature Request: Allow configuration of java executable HOT 2
- Kotlin only generated classes HOT 2
- extractIncludeProto execute so slowly
- protobuf dependency configuration is marked consumable
- Gradle Java project running into many proto related errors "cannot find symbol" randomly on compiling Java srcs
- Update sample to use latest plugin version HOT 1
- How can I compile proto files using Protobuf Editions
- Compilation of the generated code fails with protobuf 4.26.0 HOT 3
- Example/documentation for generating kotlin classes with kotlin DSL HOT 1
- Use plural form default output directory 'generated/sources'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protobuf-gradle-plugin.