-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Update task sample for java 11 #1382
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
Conversation
appengine-java11/pom.xml
Outdated
@@ -0,0 +1,49 @@ | |||
<!-- |
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.
This pom doesn't seem to do anything - it should be able to be removed.
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.
This still needs to be removed.
appengine-java11/tasks/README.md
Outdated
First, your project ID: | ||
|
||
``` | ||
export GOOGLE_CLOUD_PROJECT=<YOUR_GOOGLE_CLOUD_PROJECT> |
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.
Best practice to escape variable contents with quotes in bash.
export GOOGLE_CLOUD_PROJECT=<YOUR_GOOGLE_CLOUD_PROJECT> | |
export GOOGLE_CLOUD_PROJECT="<YOUR_GOOGLE_CLOUD_PROJECT>" |
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.
done.
appengine-java11/tasks/README.md
Outdated
created can be listed with `gcloud beta tasks queues list`. | ||
|
||
``` | ||
export QUEUE_ID=my-appengine-queue |
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.
export QUEUE_ID=my-appengine-queue | |
export QUEUE_ID="my-appengine-queue" |
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.
done.
appengine-java11/tasks/README.md
Outdated
location is "us-central1"). | ||
|
||
``` | ||
export LOCATION_ID=<YOUR_ZONE> |
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.
export LOCATION_ID=<YOUR_ZONE> | |
export LOCATION_ID="<YOUR_ZONE>" |
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.
done.
appengine-java11/tasks/pom.xml
Outdated
The parent pom defines common style checks and testing strategies for our samples. | ||
Removing or replacing it should not affect the execution of the samples in anyway. | ||
--> | ||
<!-- <parent> |
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.
Reminder to uncomment this before submitting.
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.
done.
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.
Still looks commented to me.
appengine-java11/tasks/pom.xml
Outdated
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.appengine.demo</groupId> |
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.
It might be good to have a comment or link to instructions on where the user can go to build this requirement, since it's unable to be pulled down from maven central.
A relative path might also work? Up to you.
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.
If the user comes to this sample from a link, it's unclear where they have to go for this (they may not realize the entire structure of the samples). Please expand either stating "from this repository" or add a full link so the user can take a look.
import java.time.Clock; | ||
import java.time.Instant; | ||
|
||
import org.apache.commons.cli.CommandLine; |
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.
There has been a bunch of pushback on adding CLI's to samples (the new sample format mandates you don't unless it's an explicit requirement for the sample). This is because a) it ends up being a bunch of boilerplate code, b) everyone uses a different cli framework and so it becomes a pain to maintain or update future versions. (Java is also particularly painful since it's hard to remember the correct execution syntax.)
A better alternative would be to add an HTTP endpoint that covers the task creation instead, and provide the user with instructions using curl
.
(This is up to you since there is no collective agreement on when the new samples format becomes mandatory)
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.
Removed the larger CLI; however still using main in order to be executable.
.longOpt("project-id") | ||
.desc("The Google Cloud Project, if not set as GOOGLE_CLOUD_PROJECT env var.") | ||
.hasArg() | ||
.argName("project-id") |
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.
I would suggest something like the following to make it clear that the user needs to provide their own data:
.argName("project-id") | |
.argName("your-project-id") |
|
||
// Instantiates a client. | ||
try (CloudTasksClient client = CloudTasksClient.create()) { | ||
|
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.
Nix the newline
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.
done.
// Construct the task body. | ||
Task.Builder taskBuilder = Task | ||
.newBuilder() | ||
.setAppEngineHttpRequest(AppEngineHttpRequest.newBuilder() |
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.
This line break looks like it might be a style violation (checkstyle should catch it when you get it added)
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.
done.
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.
Still seems wrong - see "Where to Line Break"
appengine-java11/tasks/pom.xml
Outdated
The parent pom defines common style checks and testing strategies for our samples. | ||
Removing or replacing it should not affect the execution of the samples in anyway. | ||
--> | ||
<!-- <parent> |
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.
Still looks commented to me.
appengine-java11/pom.xml
Outdated
@@ -0,0 +1,49 @@ | |||
<!-- |
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.
This still needs to be removed.
appengine-java11/tasks/pom.xml
Outdated
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.appengine.demo</groupId> |
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.
If the user comes to this sample from a link, it's unclear where they have to go for this (they may not realize the entire structure of the samples). Please expand either stating "from this repository" or add a full link so the user can take a look.
// Construct the task body. | ||
Task.Builder taskBuilder = Task | ||
.newBuilder() | ||
.setAppEngineHttpRequest(AppEngineHttpRequest.newBuilder() |
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.
Still seems wrong - see "Where to Line Break"
@kurtisvg I updated the task handler to a Spring Boot app and moved it to a separate directory. |
<artifactId>task-handler-j11</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<parent> |
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.
Can you run a formatter on this POM? IntelliJ has on built in
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.
done.
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> |
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.
This isn't the shared config parent - is that intentional?
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.
This is needed for Spring Boot. Adding the dependencies individually was making it more complicated but I can do that instead.
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.
I think this should be fine if the shared-config work as a dependency instead
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.
Figured out how cleanly remove this.
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.1.4.RELEASE</version> | ||
<relativePath/> <!-- lookup parent from repository --> |
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.
Is this supposed to be an open/close tag?
appengine-java11/tasks-handler/mvnw
Outdated
@@ -0,0 +1,286 @@ | |||
#!/bin/sh | |||
# ---------------------------------------------------------------------------- |
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.
Do we need to include a maven wrapper with this sample? The licensing may have ramifications.
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.
removed.
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>${spring-cloud.version}</version> |
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.
Does this need to be a property? DPE bot is unable to update versions that use these.
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.
done.
@@ -0,0 +1,34 @@ | |||
/* | |||
* Copyright 2017-2019 the original author or authors. |
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.
This license header is incorrect.
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.
done.
@@ -0,0 +1,41 @@ | |||
/* | |||
* Copyright 2017-2019 the original author or authors. |
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.
This license header is incorrect.
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.
done.
<!-- | ||
The parent pom defines common style checks and testing strategies for our samples. | ||
Removing or replacing it should not affect the execution of the samples in anyway. | ||
--> |
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.
nit: Indent this.
<groupId>com.google.cloud.samples</groupId> | ||
<artifactId>shared-configuration</artifactId> | ||
<version>1.0.11</version> | ||
<relativePath></relativePath> |
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.
You don't need to specify a relative path - should pull from maven.
No description provided.