Skip to content
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

Make getSdkPath and getJavaToolsJar public. #164

Merged
merged 6 commits into from
Jul 15, 2016
Merged

Conversation

joaoandremartins
Copy link
Contributor

@joaoandremartins joaoandremartins commented Jul 13, 2016

getSdkPath should only be used for testing in GoogleCloudPlatform/google-cloud-eclipse#335

@meltsufin @loosebazooka PTAL

@@ -174,7 +175,7 @@ private void logCommand(List<String> command) {
logger.info("submitting command: " + WHITESPACE_JOINER.join(command));
}

private Path getSdkPath() {
@VisibleForTesting public Path getSdkPath() {
Copy link
Contributor

Choose a reason for hiding this comment

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

why @VisibleForTesting? It seems useful and safe enough.

@joaoandremartins
Copy link
Contributor Author

@elharo PTAL

@elharo
Copy link
Contributor

elharo commented Jul 14, 2016

Tests appear to be failing due to:

[INFO] --- maven-checkstyle-plugin:2.17:check (default) @ appengine-plugins-core ---
[WARNING] src/main/java/com/google/cloud/tools/appengine/cloudsdk/CloudSdk.java:354 JavadocParagraph: Empty line should be followed by

tag on the next line.

This shouldn't cuase a failure though.

@@ -195,7 +195,7 @@ public Path getJavaAppEngineSdkPath() {
return getSdkPath().resolve(JAVA_APPENGINE_SDK_PATH);
}

private Path getJavaToolsJar() {
public Path getJavaToolsJar() {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if these type of methods always return a Collection<Path> or Path[] for future-proofing (what happens if AppEngine's tools is split into multiple jars)?

I think there are two approaches:

  1. The caller should know where the particular jars are situated within the Cloud SDK, in which case we just need a resolve() type method. We're doing this in the Eclipse classpath providers, where we're pulling out runtime jars (servlet-api.jar and asp-api.jar).
  2. The locations are masked by this library, and the caller instead requests them by purpose, like this method. Means we need to continue to modify and update this class as new libraries become included in the Cloud SDK.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Maybe the naming is wrong, but it's just a reference to the location of appcfg.
  2. I think the actual expectation is that no one uses these. They really should be internal. Do you guys want to use this for something more than just testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it could be fair that the client has some knowledge of the SDK structure. The alternative would be to have a method to return each and every one of the SDK JARs, which might be a bit unsightly.
What do you guys think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would like to worry about the case where the SDK is split into different directories later, when we have to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@loosebazooka it's being used for a few things in the Eclipse plugin.
Find shared/servlet-api.jar and shared/jsp-api.jar, display the current location on the text box, set it for internal use, check that the path exists (though this should really be being done at the library), etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My above response was actually for getJavaAppEngineSdkPath(). Eclipse is only using getJavaToolsJar() to add its location to the classpath IIUC.

@joaoandremartins
Copy link
Contributor Author

@elharo @briandealwis PTAL. I added JAR location resolution and some unit tests.

@@ -93,6 +95,12 @@ private CloudSdk(Path sdkPath, String appCommandMetricsEnvironment,
this.processRunner = new DefaultProcessRunner(async, stdOutLineListeners, stdErrLineListeners,
exitListeners, startListeners);

// Populate jar locations.
Copy link
Contributor

Choose a reason for hiding this comment

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

something I just discovered: not all google cloud SDK installs have this. The app-engine-java component needs to be explicitly installed.

Not for this PR, but we need to think about what happens if these paths aren't present.

Copy link
Member

Choose a reason for hiding this comment

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

And that'll be true for GKE support too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a TODO. We should probably just detect if the Java SDK is installed and ask the user to install it if it isn't.

Copy link
Contributor

Choose a reason for hiding this comment

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

@joaoandremartins that's a good idea. Can you put that down as an issue on the repository?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if we can piggyback on #165? I'll link the TODO I added there, and maybe even assign it to myself.

Copy link
Contributor

Choose a reason for hiding this comment

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

In the library we can't assume there's a user. Any asking of user needs to be done from the UI.

@elharo
Copy link
Contributor

elharo commented Jul 15, 2016

LGTM

throw new AppEngineException(
"Validation Error: Java Tools jar path '" + getJavaToolsJar() + "' is not valid");
"Validation Error: Java Tools jar path '"
+ JAR_LOCATIONS.get(JAVA_TOOLS_JAR) + "' is not valid");
Copy link
Contributor

Choose a reason for hiding this comment

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

we should have a more specific message explaining why the location is invalid

Files.isDirectory()/isRegularFile().
throw new AppEngineException(
"Validation Error: SDK directory '" + sdkPath + "' is not valid");
"Validation Error: SDK location '" + sdkPath + "' is a directory.");
Copy link
Contributor

Choose a reason for hiding this comment

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

is not a directory

@joaoandremartins joaoandremartins merged commit 20c18cc into master Jul 15, 2016
@joaoandremartins joaoandremartins deleted the tools-jar branch July 15, 2016 18:58
// Populate jar locations.
// TODO(joaomartins): Consider case where SDK doesn't contain these jars. Only App Engine
// SDK does.
JAR_LOCATIONS.put("servlet-api.jar",
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this has been submitted, but there is no guarantee these jars will exist in the future in the cloud SDK. What is the need for these?

This CL seems to be modifying more than is intended in it's title.

Copy link
Contributor

Choose a reason for hiding this comment

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

These jars are needed to setup projects in Eclipse, and to run local servers.

Copy link
Contributor

Choose a reason for hiding this comment

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

And on top of that, why provide this as a map?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's implemented as a map, but provided as API methods. Do you have any alternative suggestion?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's dangerous to have this dependency, api tools jar was purely for running staging and nothing else. The appengine sdk dependency may or may not exist in the future, we expect a standalone staging command to replace going into the java SDK here. I would generally avoid depending on anything in the java SDK included in the cloud sdk.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be difficult to get these jars from somewhere else?

Copy link
Contributor Author

@joaoandremartins joaoandremartins Jul 15, 2016

Choose a reason for hiding this comment

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

The tools jar is used in https://github.com/GoogleCloudPlatform/gcloud-eclipse-tools/blob/master/plugins/com.google.cloud.tools.eclipse.appengine.facets/src/com/google/cloud/tools/eclipse/appengine/facets/AppEngineSdkClasspathContainer.java#L40. I just assumed it was needed and bundled the change due to the same requirement in https://github.com/GoogleCloudPlatform/gcloud-eclipse-tools/blob/master/plugins/com.google.cloud.tools.eclipse.appengine.localserver/src/com/google/cloud/tools/eclipse/appengine/localserver/ServletClasspathProvider.java#L39.

If the jars are in fact needed, then I think they should come from the SDK, hence the library should give them.

Although I agree that any functionality should probably be provided through an API, not JAR imports, that is a separate conversation to this PR.

@joaoandremartins
Copy link
Contributor Author

Paths were already used over Files on the proof-of-concept implementation, at first, as per Patrick's suggestion and best practices.
I seem to recall having commented on the usage of File on your big PR, but maybe that comment fell through the cracks.

I couldn't make out any other changes to the existing API that caused disruption.

@elharo
Copy link
Contributor

elharo commented Jul 15, 2016

If we're going to run a local Java server, and if that is a function of gcloud (a critical function I would argue) then I don't see how it can be without servlet.jar and these other jars somewhere. If gcloud moves these, then this API gives us enough indirection to reflect the new location without changing clients.

@loosebazooka
Copy link
Contributor

Is there somewhere you can point me to where you are using these jars?

@elharo
Copy link
Contributor

elharo commented Jul 16, 2016

We add these to the classpath when creating a new App Engine project in Eclipse, or adding the App Engine facet to an existing non-maven project.

They're also implicitly used when running a local development server.

@joaoandremartins
Copy link
Contributor Author

@loosebazooka @meltsufin do we have to wait for a new release to upload new changes to Sonatype? GoogleCloudPlatform/google-cloud-eclipse#335 depends on this change and I can't submit it until these changes are published.

JoeWang1127 pushed a commit that referenced this pull request Nov 29, 2023
* Make getSdkPath public for testing.

* Fixes an issue with resolving paths in CloudSdk and adds unit tests.

* Replaced toFile() with Files.isDirectory()/isRegularFile().
JoeWang1127 pushed a commit that referenced this pull request Nov 29, 2023
… configuration based on dev appserver 1 or 2-alpha. (#165)

* WIP - Fixes #158 - dev appserver 1 stuff

* javadoc and simpler code whether checking <services> parameter has been configured by the user

* remove default value from appYamls, revert file->path change

* unit tests for RunMojo

* update appengine-plugins-core dependency to 0.3.0

* try to fix kokoro test

* use custom ports to test run in integration test to avoid port clash on Kokoro

* fix async run test as well for Kokoro

* Fixes #158 - dev appserver 1 stuff

* additional tests

* add datastorePath to RunMojo

* add javadoc to datastorePath

* increase timeout to see if it fixes the kokoro-ubuntu build

* reformat pom.xml dependency for junitparams, rename SupportedVersion to SupportedDevServerVersion
JoeWang1127 pushed a commit that referenced this pull request Nov 29, 2023
* preserve datastore-indexes-auto across non-clean rebuilds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants