Comments (8)
The hardest part of this seems to be "support Java protoc plugins." After that, it seems it would be easy to provide a way to override the mainClass (I assume because the JAR did not set one in its metadata).
It does seem that the plugin would have to generate a .sh or .bat file to be executed by protoc.
from protobuf-gradle-plugin.
So, if I don't find a .exe
file in the artifact, but find a .jar
file, I would assume it is a Java plugin. In that case, I would generate a .sh
or .bat
file to be executed by protoc
.
I am not yet sure if .bat
file works under windows, because the Maven protoc plugin makes use of winrun4j.
from protobuf-gradle-plugin.
Yeah, it might not; it may require calling cmd.exe, which would defeat the purpose. The Maven protoc plugin logic seems sane; mimicking it would be reasonable.
from protobuf-gradle-plugin.
FWIW, the "specify main method" thing isn't actually important to me, I realized the jar is actually executable already. Main thing is to just support .jar plugins. My current workaround:
#!/bin/sh
curl https://my-maven-server.com/content/groups/public/com/mycompany/protobuf/protobuf-plugin/1.3/protobuf-plugin-1.3-shaded.jar > protobuf-plugin-1.3-shaded.jar
java -jar protobuf-plugin-1.3-shaded.jar
rm protobuf-plugin-1.3-shaded.jar
from protobuf-gradle-plugin.
From https://github.com/google/protobuf-gradle-plugin/blob/master/src/main/groovy/com/google/protobuf/gradle/ToolsLocator.groovy#L84, it looks to me that all that's needed is for some way to override the classifier
and extension
fields. This solution would also be generic in that the codegen plugin can be implemented in any language. Those wanting to use Java would then follow something like http://en.newinstance.it/2012/04/17/self-executing-jar-files/ to build the executable.
from protobuf-gradle-plugin.
@zhangkun83 , I'd like to implement the above PR. One issue is that if we stick with the Gradle syntax described in https://docs.gradle.org/3.3/userguide/dependency_management.html#sub:classifiers, it would break backwards compatibility since existing users will have to start specifying explicitly the classifier
part as ${os.detector.classifier}
and the extension
as exe
.
One alternative is to create some other syntax (perhaps a field indicating the classifier and extension).
My personal preference would be to break backwards compatibility now while the version of the plugin is 0.+
rather than to introduce syntax that's inconsistent with the rest of Gradle. What do you think?
from protobuf-gradle-plugin.
Actually, I see a way to maintain backwards compatibility -- developers of the codegen plugin publish with a classifier
(eg jvm8
) and the extension
can still default to exe
. When resolving the codegen plugin dependency, if a classifier
isn't specified, it'll still default to using os.detector.classifier
.
from protobuf-gradle-plugin.
If you're looking at a somewhat complete example, you might wish to have a look here: https://github.com/Xorlev/grpc-jersey/blob/master/build.gradle
from protobuf-gradle-plugin.
Related Issues (20)
- 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
- Plugin not compiling java code after migration from 0.8.19 -> 0.9.0 HOT 8
- 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'
- Kotlin only proto Unresolved reference
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.