Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose a way to query builtins/plugins at Gradle configuration time #49

Closed
JakePi3 opened this issue Nov 4, 2015 · 3 comments
Closed
Assignees

Comments

@JakePi3
Copy link

JakePi3 commented Nov 4, 2015

A bit of background first... I am trying to generate both Java and C++ bindings and then publish the Java classes as well as the C++ source files to a Maven repository.

I currently have:

protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.0.0-beta-1'
    }
    generateProtoTasks {
        all().each { t ->
            t.builtins {
                cpp {}
            }
        }
    }
}

task zipCpp(type: Zip, dependsOn: 'generateProto') {
    from "${buildDir}/generated/source/proto/main/cpp"
}
assemble.dependsOn zipCpp

It would be nice if the zip task could discover the outputs of a builtin with a given name.. Something like:

task zipCpp(type: Zip, dependsOn: 'generateProto') {
    from tasks.getByName('generateProto') { t ->
        t.builtins.findAll { it.name == 'cpp' }.each { b->
            t.outputDir(b)
        }
    }
}

Or even better, move some of that complexity into the actual plugin.. At the moment the task is not available at configuration time and moving the creation of the zip task to inside the generateProtoTasks closure is even more complicated. Suggestions/workarounds welcome.

@zhangkun83 zhangkun83 self-assigned this Nov 5, 2015
@zhangkun83
Copy link
Collaborator

As documented, we suggest not assuming the names of the generate proto tasks, thus all configurations that are related to these tasks should be done in the generateProtoTasks closure.

This would get what you want:

task zipCpp(type: Zip) {
}

protobuf {
  ...
  generateProtoTasks {
    ...
    zipCpp {
      dependsOn ofSourceSet('main')
      from ofSourceSet('main').collectMany { t ->
        t.builtins.findAll { it.name == 'java' }.collect { b->
          t.getOutputDir(b)
        }
      }
    }
  }

It's not working at current version because t.builtins is not a readable property. If the general solution sounds good to you, I can make the property readable.

@JakePi3
Copy link
Author

JakePi3 commented Nov 6, 2015

Yes, this is great. Maybe make t.plugins also readable for same reason...

Thanks.

@zhangkun83
Copy link
Collaborator

0.7.1 is now released. builtins and plugins are now readable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants