Skip to content

Ore Deploy plugin - #9

Merged
Zidane merged 1 commit into
SpongePowered:masterfrom
windy1:feature/ore-deploy
Feb 26, 2018
Merged

Zidane merged 1 commit into
SpongePowered:masterfrom
windy1:feature/ore-deploy

Conversation

@windy1

@windy1 windy1 commented Mar 28, 2017

Copy link
Copy Markdown


class OreDeployExtension {

String instanceUrl = 'http://localhost:9000'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably makes more sense to default this to https://ore.spongepowered.org

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"WIP" :P

@simon816

simon816 commented Mar 28, 2017 •

Copy link
Copy Markdown

Am I right in thinking that we were going to have a maven deploy endpoint on Ore? (i.e. running an uploadArchives task)

Is this gradle integration a replacement for that or just a 'filler' before full maven support is added?
Edit: or in addition to maven support?

@windy1

windy1 commented Mar 29, 2017

Copy link
Copy Markdown
Author

@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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this task isn't defined? Should we automatically apply and configure the signing plugin?

@windy1 windy1 Mar 29, 2017 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Groovy has a convenient OutputStream.withStream method that will automatically handle closing the stream

@stephan-gh
stephan-gh self-requested a review March 31, 2017 12:59
printErrorStream is
is.close()
is = null
throw new GradleException()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@windy1 windy1 Mar 31, 2017 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 stephan-gh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for switching the http client 👍

throw new IOException('An unexpected error occurred.', e)
} finally {
if (response != null) {
response.close()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Groovy has .withCloseable similar to .withStream that does this automatically

if (response != null) {
response.close()
}
http.close()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constructor accepts a String so you can just pass in the string url directly here instead of parsing it into an URL first.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but I would rather catch the exception for a malformed URL to provide a more useful error.

@windy1 windy1 changed the title [WIP] Ore Deploy plugin Ore Deploy plugin Apr 10, 2017
@windy1

windy1 commented Apr 10, 2017

Copy link
Copy Markdown
Author

@Minecrell Can you think of anything else before this goes in?

@stephan-gh

Copy link
Copy Markdown

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

@windy1

windy1 commented Apr 10, 2017

Copy link
Copy Markdown
Author

Sure, no problem. 👍

void run() {
Logger logger = project.logger
def artifacts = deploy.allArtifacts
PublishArtifact plugin = artifacts.find { a -> (a.type == "jar") }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which artifact is uploaded? Is it configurable?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Asherslab

Asherslab commented Oct 17, 2017 •

Copy link
Copy Markdown

This looks like an absolutely awesome thing, is this ready to go? I'd love to see this soon

@windy1

windy1 commented Oct 25, 2017

Copy link
Copy Markdown
Author

@Asherslab It was working last time I tested it, could probably be improved upon, but could probably go in.

@Asherslab

Copy link
Copy Markdown

Sounds awesome! I could really use this whenever it gets merged in. Thanks for the work!

@Asherslab

Copy link
Copy Markdown

So, i take it this just needs a review from someone else to get merged?
(If there's anyway i can use it now that'd be cool too, but either way) 😄

@windy1

windy1 commented Oct 31, 2017

Copy link
Copy Markdown
Author

@Asherslab Essentially, you can build the project yourself if you're like to use it. Should work.

@Asherslab

Asherslab commented Nov 1, 2017 •

Copy link
Copy Markdown

Hi @windy1, thanks, i successfully built it myself just after i sent that (sorry)

i do have a bit of an error though, and i'm not sure if that's my fault or a bug:

Gradle Error: https://gist.github.com/Asherslab/a7b357a2e58becace55eca2dc292f4e6
build.gradle (With sensitive info removed): https://github.com/Minecolonies/Rankup/blob/API-6/feature/concurrant-tracks/build.gradle
(I also tried adding the line oreDeploy.instanceUrl = "https://ore.spongepowered.org/Asherslab/Rankup" incase that was part of the error)

EDIT:
I just realised that I'm an idiot and didn't add the apache client dependency to my build.gradle! learning learning, sorry for the trouble

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!

@Zidane
Zidane merged commit 0030e17 into SpongePowered:master Feb 26, 2018
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

Successfully merging this pull request may close these issues.

7 participants