Repository navigation
Ore Deploy plugin - #9
Conversation
|
|
||
| class OreDeployExtension { | ||
|
|
||
| String instanceUrl = 'http://localhost:9000' |
There was a problem hiding this comment.
Probably makes more sense to default this to https://ore.spongepowered.org
|
Am I right in thinking that we were going to have a maven deploy endpoint on Ore? (i.e. running an Is this gradle integration a replacement for that or just a 'filler' before full maven support is added? |
|
@simon816 I think maven support could potentially be built on top of this, but I wanted something that just hooked into the current system as well for simplicity's sake. Working maven into the current file system is a much larger undertaking. |
|
|
||
| conn.connect() | ||
| if (conn.responseCode != HttpURLConnection.HTTP_CREATED) { | ||
| println '[failure] ' + conn.responseCode + ' ' + conn.responseMessage |
There was a problem hiding this comment.
You should use the logger of the task here (just get the logger property of the task)
| project.with { | ||
| extensions.create('oreDeploy', OreDeployExtension) | ||
| def task = task('oreDeploy', type: OreDeployTask) | ||
| task.dependsOn('signArchives') |
There was a problem hiding this comment.
What if this task isn't defined? Should we automatically apply and configure the signing plugin?
There was a problem hiding this comment.
Probably not considering, their pub/priv keys will need to be configured properly by the user and will likely just cause confusion IMO.
|
|
||
| os = conn.outputStream | ||
| requestEntity.writeTo(os) | ||
| os.flush() |
There was a problem hiding this comment.
Groovy has a convenient OutputStream.withStream method that will automatically handle closing the stream
| printErrorStream is | ||
| is.close() | ||
| is = null | ||
| throw new GradleException() |
There was a problem hiding this comment.
You should also use conn.errorStream.withStream here. Also, instead of printing the error to the logger and then throwing the exception you should include the error message in the exception. Otherwise, Gradle will display an error with (no error message)
There was a problem hiding this comment.
I actually tried using withStream with the InputStreams but it was behaving very strangely. AFAI could tell it was down-casting the stream to the HttpURLConnection anonymous implementing class and then couldn't find a method declaration for printErrorStream with that sub-class. Very odd.
| } catch (InterruptedIOException | SocketException ignored) { | ||
| throw new GradleException('Failed to connect to Ore.') | ||
| } catch (SSLHandshakeException ignored) { | ||
| logger.error('[failure] Outdated Java!') |
There was a problem hiding this comment.
I think it would make more sense if we include this message in the exception below
| if (channel == null) { | ||
| throw new InvalidUserDataException("Missing channel name.") | ||
| } | ||
| HttpEntity requestEntity = MultipartEntityBuilder.create() |
There was a problem hiding this comment.
You use the API from Apache's http client here, but send the request using Java's API. Since the full http client is downloaded for this anyway, would it be nicer to use Apache's http client entirely for sending the request?
There was a problem hiding this comment.
Sure, I really just used this API because writing multipart form data is a huge PITA from scratch (I've done it before). I quick Google search says that HttpClient is optimized for performance however so I have nothing against switching.
Signed-off-by: Walker Crouse <walkercrouse@hotmail.com>
stephan-gh
left a comment
There was a problem hiding this comment.
Thanks for switching the http client 👍
| throw new IOException('An unexpected error occurred.', e) | ||
| } finally { | ||
| if (response != null) { | ||
| response.close() |
There was a problem hiding this comment.
Groovy has .withCloseable similar to .withStream that does this automatically
| if (response != null) { | ||
| response.close() | ||
| } | ||
| http.close() |
There was a problem hiding this comment.
I'm having the same issue with the response entity's InputStream being down-casted when in the closure again for some reason.
| logger.debug(requestEntity.toString()) | ||
|
|
||
| HttpClient http = HttpClients.createDefault() | ||
| HttpPost post = new HttpPost(projectUrl.toURI()) |
There was a problem hiding this comment.
The constructor accepts a String so you can just pass in the string url directly here instead of parsing it into an URL first.
There was a problem hiding this comment.
Yeah but I would rather catch the exception for a malformed URL to provide a more useful error.
|
@Minecrell Can you think of anything else before this goes in? |
|
@windy1 Not right now, but if you don't mind waiting until tomorrow I'd still like to look at some of the Gradle implementation details. |
|
Sure, no problem. 👍 |
| void run() { | ||
| Logger logger = project.logger | ||
| def artifacts = deploy.allArtifacts | ||
| PublishArtifact plugin = artifacts.find { a -> (a.type == "jar") } |
There was a problem hiding this comment.
Which artifact is uploaded? Is it configurable?
There was a problem hiding this comment.
It looks like it publishes everything in the archives block if it's a jar.
A lot of plugins have sources, javadocs, raw, and then dist jars in there. It'd be a massive improvement to allow specifying what is published to Ore separately.
|
This looks like an absolutely awesome thing, is this ready to go? I'd love to see this soon |
|
@Asherslab It was working last time I tested it, could probably be improved upon, but could probably go in. |
|
Sounds awesome! I could really use this whenever it gets merged in. Thanks for the work! |
|
So, i take it this just needs a review from someone else to get merged? |
|
@Asherslab Essentially, you can build the project yourself if you're like to use it. Should work. |
|
Hi @windy1, thanks, i successfully built it myself just after i sent that (sorry)
EDIT: i would post this as an issue in your fork, but you don't have an issues tab there. and i feel like making an issue for a non-merged PR here wouldn't be okay (Feel free to tell me to make an issue here 😄 ) Thanks for your work! |
Corresponding Ore branch: https://github.com/SpongePowered/Ore/tree/feature/gradle-deploy
Signed-off-by: Walker Crouse walkercrouse@hotmail.com