com.google.cloud.tools.appengine.operations.cloudsdk.AppEngineJavaComponentsNotInstalledException Java Examples
The following examples show how to use
com.google.cloud.tools.appengine.operations.cloudsdk.AppEngineJavaComponentsNotInstalledException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CheckCloudSdkTask.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
/** Task entrypoint : Verify Cloud SDK installation. */ @TaskAction public void checkCloudSdkAction() throws CloudSdkNotFoundException, CloudSdkVersionFileException, CloudSdkOutOfDateException, AppEngineJavaComponentsNotInstalledException { // These properties are only set by AppEngineCorePluginConfiguration if the correct config // params are set in the tools extension. if (Strings.isNullOrEmpty(version) || cloudSdk == null) { throw new GradleException( "Cloud SDK home path and version must be configured in order to run this task."); } if (!version.equals(cloudSdk.getVersion().toString())) { throw new GradleException( "Specified Cloud SDK version (" + version + ") does not match installed version (" + cloudSdk.getVersion() + ")."); } cloudSdk.validateCloudSdk(); if (requiresAppEngineJava) { cloudSdk.validateAppEngineJavaComponents(); } }
Example #2
Source File: AppCfgRunner.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
/** * Executes an App Engine SDK CLI command. * * @throws AppEngineJavaComponentsNotInstalledException when the App Engine Java components are * not installed in the Cloud SDK * @throws InvalidJavaSdkException java not found */ public void run(List<String> args) throws ProcessHandlerException, AppEngineJavaComponentsNotInstalledException, InvalidJavaSdkException, IOException { sdk.validateAppEngineJavaComponents(); sdk.validateJdk(); // App Engine Java Sdk requires this system property to be set. // TODO: perhaps we should send this in directly to the command instead of changing the global // state here (see DevAppServerRunner) System.setProperty("appengine.sdk.root", sdk.getAppEngineSdkForJavaPath().toString()); List<String> command = new ArrayList<>(); command.add(sdk.getJavaExecutablePath().toString()); command.add("-cp"); command.add(sdk.getAppEngineToolsJar().toString()); command.add("com.google.appengine.tools.admin.AppCfg"); command.addAll(args); logger.info("submitting command: " + Joiner.on(" ").join(command)); ProcessBuilder processBuilder = processBuilderFactory.newProcessBuilder(); processBuilder.command(command); Process process = processBuilder.start(); processHandler.handleProcess(process); }
Example #3
Source File: AppEngineWebXmlProjectStagingTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Before public void setUp() throws IOException, InvalidJavaSdkException, ProcessHandlerException, AppEngineJavaComponentsNotInstalledException { source = tmpDir.newFolder("source").toPath(); destination = tmpDir.newFolder("destination").toPath(); dockerfile = tmpDir.newFile("dockerfile").toPath(); staging = new AppEngineWebXmlProjectStaging(appCfgRunner); builder = AppEngineWebXmlProjectStageConfiguration.builder() .sourceDirectory(source) .stagingDirectory(destination); // create an app.yaml in staging output when we run. Mockito.doAnswer( ignored -> { Files.createFile(destination.resolve("app.yaml")); return null; }) .when(appCfgRunner) .run(Mockito.anyList()); }
Example #4
Source File: AppCfgRunnerTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void testRun() throws InvalidJavaSdkException, ProcessHandlerException, AppEngineJavaComponentsNotInstalledException, IOException { AppCfgRunner appCfgRunner = new AppCfgRunner.Factory(processBuilderFactory).newRunner(sdk, processHandler); appCfgRunner.run(ImmutableList.of("some", "command")); Mockito.verify(processBuilder) .command( ImmutableList.of( javaExecutablePath.toString(), "-cp", appengineToolsJar.toString(), "com.google.appengine.tools.admin.AppCfg", "some", "command")); Mockito.verify(processBuilder).start(); Mockito.verifyNoMoreInteractions(processBuilder); Mockito.verify(processHandler).handleProcess(process); Assert.assertEquals(appengineJavaSdkPath.toString(), System.getProperty("appengine.sdk.root")); }
Example #5
Source File: CloudSdkAppEngineFactoryTest.java From app-maven-plugin with Apache License 2.0 | 6 votes |
@Test public void testBuildCloudSdk_checkAppEngine() throws CloudSdkOutOfDateException, CloudSdkNotFoundException, CloudSdkVersionFileException, AppEngineJavaComponentsNotInstalledException { when(mojoMock.getCloudSdkHome()).thenReturn(CLOUD_SDK_HOME); when(mojoMock.getCloudSdkVersion()).thenReturn(CLOUD_SDK_VERSION); // invoke CloudSdk sdk = CloudSdkAppEngineFactory.buildCloudSdk(mojoMock, cloudSdkChecker, cloudSdkDownloader, true); // verify Assert.assertEquals(CLOUD_SDK_HOME, sdk.getPath()); verify(cloudSdkChecker).checkCloudSdk(sdk, CLOUD_SDK_VERSION); verify(cloudSdkChecker).checkForAppEngine(sdk); verifyNoMoreInteractions(cloudSdkDownloader); verifyNoMoreInteractions(cloudSdkChecker); }
Example #6
Source File: CheckCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testCheckCloudSdkAction_nullVersion() throws CloudSdkNotFoundException, CloudSdkVersionFileException, CloudSdkOutOfDateException, AppEngineJavaComponentsNotInstalledException { checkCloudSdkTask.setVersion(null); try { checkCloudSdkTask.checkCloudSdkAction(); Assert.fail(); } catch (GradleException ex) { Assert.assertEquals( "Cloud SDK home path and version must be configured in order to run this task.", ex.getMessage()); } }
Example #7
Source File: CheckCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testCheckCloudSdkAction_versionMismatch() throws CloudSdkVersionFileException, CloudSdkNotFoundException, CloudSdkOutOfDateException, AppEngineJavaComponentsNotInstalledException { checkCloudSdkTask.setVersion("191.0.0"); when(sdk.getVersion()).thenReturn(new CloudSdkVersion("190.0.0")); try { checkCloudSdkTask.checkCloudSdkAction(); Assert.fail(); } catch (GradleException ex) { Assert.assertEquals( "Specified Cloud SDK version (191.0.0) does not match installed version (190.0.0).", ex.getMessage()); } }
Example #8
Source File: CheckCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testCheckCloudSdkAction_callPluginsCoreChecks() throws CloudSdkVersionFileException, CloudSdkNotFoundException, CloudSdkOutOfDateException, AppEngineJavaComponentsNotInstalledException { checkCloudSdkTask.setVersion("192.0.0"); checkCloudSdkTask.requiresAppEngineJava(true); when(sdk.getVersion()).thenReturn(new CloudSdkVersion("192.0.0")); checkCloudSdkTask.checkCloudSdkAction(); Mockito.verify(sdk).getVersion(); Mockito.verify(sdk).validateCloudSdk(); Mockito.verify(sdk).validateAppEngineJavaComponents(); Mockito.verifyNoMoreInteractions(sdk); }
Example #9
Source File: CheckCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testCheckCloudSdkAction_callPluginsCoreChecksSkipJava() throws CloudSdkVersionFileException, CloudSdkNotFoundException, CloudSdkOutOfDateException, AppEngineJavaComponentsNotInstalledException { checkCloudSdkTask.setVersion("192.0.0"); when(sdk.getVersion()).thenReturn(new CloudSdkVersion("192.0.0")); checkCloudSdkTask.checkCloudSdkAction(); Mockito.verify(sdk).getVersion(); Mockito.verify(sdk).validateCloudSdk(); Mockito.verify(sdk, Mockito.never()).validateAppEngineJavaComponents(); Mockito.verifyNoMoreInteractions(sdk); }
Example #10
Source File: DevAppServerRunner.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
/** * Uses the process runner to execute the classic Java SDK devappsever command. * * @param jvmArgs the arguments to pass to the Java Virtual machine that launches the devappserver * @param args the arguments to pass to devappserver * @param environment the environment to set on the devappserver process * @param workingDirectory if null then the working directory of current Java process. * @throws ProcessHandlerException when process runner encounters an error * @throws AppEngineJavaComponentsNotInstalledException Cloud SDK is installed but App Engine Java * components are not * @throws InvalidJavaSdkException when the specified JDK does not exist */ public void run( List<String> jvmArgs, List<String> args, Map<String, String> environment, @Nullable Path workingDirectory) throws ProcessHandlerException, AppEngineJavaComponentsNotInstalledException, InvalidJavaSdkException, IOException { sdk.validateAppEngineJavaComponents(); sdk.validateJdk(); List<String> command = new ArrayList<>(); command.add(sdk.getJavaExecutablePath().toAbsolutePath().toString()); command.addAll(jvmArgs); command.add( "-Dappengine.sdk.root=" + sdk.getAppEngineSdkForJavaPath().getParent().toAbsolutePath().toString()); command.add("-cp"); command.add(sdk.getAppEngineToolsJar().toAbsolutePath().toString()); command.add("com.google.appengine.tools.development.DevAppServerMain"); command.addAll(args); logger.info("submitting command: " + Joiner.on(" ").join(command)); Map<String, String> devServerEnvironment = Maps.newHashMap(environment); devServerEnvironment.put("JAVA_HOME", sdk.getJavaHomePath().toAbsolutePath().toString()); ProcessBuilder processBuilder = processBuilderFactory.newProcessBuilder(); processBuilder.command(command); if (workingDirectory != null) { processBuilder.directory(workingDirectory.toFile()); } processBuilder.environment().putAll(devServerEnvironment); Process process = processBuilder.start(); processHandler.handleProcess(process); }
Example #11
Source File: CloudSdk.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
/** * Checks whether the App Engine Java components are installed in the expected location in the * Cloud SDK. * * @throws AppEngineJavaComponentsNotInstalledException when the App Engine Java components are * not installed in the Cloud SDK */ public void validateAppEngineJavaComponents() throws AppEngineJavaComponentsNotInstalledException { if (!Files.isDirectory(getAppEngineSdkForJavaPath())) { throw new AppEngineJavaComponentsNotInstalledException( "Validation Error: Java App Engine components not installed." + " Fix by running 'gcloud components install app-engine-java' on command-line."); } if (!Files.isRegularFile(jarLocations.get(JAVA_TOOLS_JAR))) { throw new AppEngineJavaComponentsNotInstalledException( "Validation Error: Java Tools jar location '" + jarLocations.get(JAVA_TOOLS_JAR) + "' is not a file."); } }
Example #12
Source File: DevServersRunnerTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testRun() throws InvalidJavaSdkException, ProcessHandlerException, AppEngineJavaComponentsNotInstalledException, IOException { DevAppServerRunner devAppServerRunner = new DevAppServerRunner.Factory(processBuilderFactory).newRunner(sdk, processHandler); Map<String, String> inputMap = ImmutableMap.of("ENV_KEY", "somevalue"); devAppServerRunner.run( ImmutableList.of("-XsomeArg"), ImmutableList.of("args1", "args2"), inputMap, workingDirectory); Mockito.verify(processBuilder) .command( ImmutableList.of( javaExecutablePath.toString(), "-XsomeArg", "-Dappengine.sdk.root=" + appengineSdkForJavaPath.getParent().toString(), "-cp", appengineToolsJar.toString(), "com.google.appengine.tools.development.DevAppServerMain", "args1", "args2")); Map<String, String> expectedEnv = new HashMap<>(inputMap); expectedEnv.put("JAVA_HOME", javaHomePath.toAbsolutePath().toString()); Mockito.verify(processBuilder).environment(); Mockito.verify(processEnv).putAll(expectedEnv); Mockito.verify(processBuilder).directory(workingDirectory.toFile()); Mockito.verify(processBuilder).start(); Mockito.verifyNoMoreInteractions(processBuilder); Mockito.verify(processHandler).handleProcess(process); }
Example #13
Source File: CloudSdkAppEngineFactory.java From app-maven-plugin with Apache License 2.0 | 5 votes |
static CloudSdk buildCloudSdk( CloudSdkMojo mojo, CloudSdkChecker cloudSdkChecker, CloudSdkDownloader cloudSdkDownloader, boolean requiresAppEngineComponents) { try { if (mojo.getCloudSdkHome() != null) { // if user defined CloudSdk cloudSdk = new CloudSdk.Builder().sdkPath(mojo.getCloudSdkHome()).build(); if (mojo.getCloudSdkVersion() != null) { cloudSdkChecker.checkCloudSdk(cloudSdk, mojo.getCloudSdkVersion()); } if (requiresAppEngineComponents) { cloudSdkChecker.checkForAppEngine(cloudSdk); } return cloudSdk; } else { // we need to use a managed cloud sdk List<SdkComponent> requiredComponents = new ArrayList<>(); if (requiresAppEngineComponents) { requiredComponents.add(SdkComponent.APP_ENGINE_JAVA); } return new CloudSdk.Builder() .sdkPath( cloudSdkDownloader.downloadIfNecessary( mojo.getCloudSdkVersion(), mojo.getLog(), requiredComponents, mojo.getMavenSession().isOffline())) .build(); } } catch (CloudSdkNotFoundException | CloudSdkVersionFileException | AppEngineJavaComponentsNotInstalledException | CloudSdkOutOfDateException ex) { throw new RuntimeException(ex); } }
Example #14
Source File: CloudSdkTest.java From appengine-plugins-core with Apache License 2.0 | 4 votes |
@Test public void testValidateAppEngineJavaComponents() throws AppEngineJavaComponentsNotInstalledException, CloudSdkNotFoundException { new CloudSdk.Builder().build().validateAppEngineJavaComponents(); }
Example #15
Source File: CloudSdkChecker.java From app-maven-plugin with Apache License 2.0 | 4 votes |
public void checkForAppEngine(CloudSdk cloudSdk) throws AppEngineJavaComponentsNotInstalledException { cloudSdk.validateAppEngineJavaComponents(); }
Example #16
Source File: CloudSdkCheckerTest.java From app-maven-plugin with Apache License 2.0 | 4 votes |
@Test public void testCheckForAppEngine_smokeTest() throws AppEngineJavaComponentsNotInstalledException { cloudSdkChecker.checkForAppEngine(sdk); verify(sdk).validateAppEngineJavaComponents(); }