Giter VIP home page Giter VIP logo

Comments (8)

dl6lr avatar dl6lr commented on June 2, 2024

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.

ejona86 avatar ejona86 commented on June 2, 2024

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.

dl6lr avatar dl6lr commented on June 2, 2024

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.

ejona86 avatar ejona86 commented on June 2, 2024

@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.

dl6lr avatar dl6lr commented on June 2, 2024

@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.

ejona86 avatar ejona86 commented on June 2, 2024

@dl6lr, seems your issue is different. Please open a separate issue (you can link to your initial comment here).

from protobuf-gradle-plugin.

dl6lr avatar dl6lr commented on June 2, 2024

@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.

chop-suey avatar chop-suey commented on June 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.