-
Notifications
You must be signed in to change notification settings - Fork 275
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
Gradle dsl to specify the mainClass for protocPlugin #738
base: master
Are you sure you want to change the base?
Changes from 1 commit
337d8c4
586bda0
710bb0b
8242dee
a0cb402
d509edc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,7 @@ class ToolsLocator { | |
conf.visible = false | ||
conf.transitive = false | ||
} | ||
def mainClass = locator.mainClass | ||
String groupId, artifact, version, classifier, extension | ||
OsDetector osdetector = project.extensions.getByName("osdetector") as OsDetector | ||
List<String> parts = artifactParts(locator.artifact) | ||
|
@@ -104,8 +105,8 @@ class ToolsLocator { | |
group:groupId, | ||
name:artifact, | ||
version:version, | ||
classifier:classifier ?: osdetector.classifier, | ||
ext:extension ?: 'exe', | ||
classifier:classifier ?: mainClass ? null : osdetector.classifier, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mainClass should virtually never be specified. In your specific case for dubbo it makes some sense, as the JAR has multiple generators inside. But the recommendation is "the JAR should be stand-alone, with main-class specified in the meta-inf". So I doubt we want these two lines of convenience, as it creates a perverse incentive. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If mainClass can be specified, it will be more convenient to use. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am currently in urgent need of this feature. Without it, I may need to maintain multiple jars separately to complete it, and others may also need to find other ways to solve this problem There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not want to encourage mainClass; most cases there should only be a single class. Allowing alternative classes and encouraging never having Main-Class in the jar are two very different things. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used translation software which may not convey the message accurately. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem isn't limited to "allowing alternative classes to be the main class." The problem you're seeing looks to impact all usages of jars. My point here is I don't want behavior tied to overriding the main class. Whatever solution here is needed should also be available when using the main-class from inside the jar. Taking a look at ServiceTalk, it looks like they are just specifying a classifier ( Do you only need dubbo-compiler support? It looks like their jar doesn't include dependencies, so I don't think the null classifier would have worked. I'm impressed that Dubbo has gone out of their way to make the exe's. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand theoretically wanting a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I want to use dubbo compiler. I have recompiled a complete jar in my private library |
||
ext:extension ?: mainClass ? 'jar' : 'exe', | ||
] | ||
project.dependencies.add(config.name, notation) | ||
locator.resolve(config, "$groupId:$artifact:$version".toString()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this doesn't actually work for other people, I don't think it makes sense as an example. Looks like we don't have an example already for jar files? Oh, well. servicetalk might be a fair example if we were searching for one.