com.google.cloud.tools.appengine.configuration.GenRepoInfoFileConfiguration Java Examples

The following examples show how to use com.google.cloud.tools.appengine.configuration.GenRepoInfoFileConfiguration. 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: GenRepoInfoFile.java    From appengine-plugins-core with Apache License 2.0 6 votes vote down vote up
/**
 * Generates source context files.
 *
 * <p>It is possible for the process to return an error code. In that case, no exception is
 * thrown, but the code must be caught with a {@link
 * com.google.cloud.tools.appengine.operations.cloudsdk.process.ProcessExitListener} attached to
 * the {@link CloudSdk} object used to run the command.
 *
 * @param configuration contains the source and output directories
 * @throws AppEngineException when there is an issue running the gcloud process
 */
public void generate(GenRepoInfoFileConfiguration configuration) throws AppEngineException {
  List<String> arguments = new ArrayList<>();

  arguments.add("beta");
  arguments.add("debug");
  arguments.add("source");
  arguments.add("gen-repo-info-file");
  arguments.addAll(GcloudArgs.get("output-directory", configuration.getOutputDirectory()));
  arguments.addAll(GcloudArgs.get("source-directory", configuration.getSourceDirectory()));

  try {
    runner.run(arguments, null);
  } catch (ProcessHandlerException | IOException ex) {
    throw new AppEngineException(ex);
  }
}
 
Example #2
Source File: GenRepoInfoFileTest.java    From appengine-plugins-core with Apache License 2.0 6 votes vote down vote up
@Test
public void testGenerate() throws AppEngineException, ProcessHandlerException, IOException {
  GcloudRunner gcloudRunner = Mockito.mock(GcloudRunner.class);
  GenRepoInfoFile model = new GenRepoInfoFile(gcloudRunner);
  GenRepoInfoFileConfiguration configuration =
      GenRepoInfoFileConfiguration.builder()
          .outputDirectory(Paths.get("output"))
          .sourceDirectory(Paths.get("source"))
          .build();
  model.generate(configuration);

  List<String> arguments =
      ImmutableList.of(
          "beta",
          "debug",
          "source",
          "gen-repo-info-file",
          "--output-directory",
          Paths.get("output").toAbsolutePath().toString(),
          "--source-directory",
          Paths.get("source").toAbsolutePath().toString());
  Mockito.verify(gcloudRunner).run(arguments, null);
}
 
Example #3
Source File: GenRepoInfoFileMojo.java    From app-maven-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
  if (skip) {
    getLog().info("Skipping appengine:genRepoInfoFile");
    return;
  }
  try {
    getAppEngineFactory()
        .genRepoInfoFile()
        .generate(
            GenRepoInfoFileConfiguration.builder()
                .outputDirectory(outputDirectory == null ? null : outputDirectory.toPath())
                .sourceDirectory(sourceDirectory == null ? null : sourceDirectory.toPath())
                .build());
  } catch (AppEngineException aee) {
    if (!ignoreErrors) {
      throw new MojoExecutionException(HOW_TO_FIX_MSG, aee);
    } else {
      logger.warning(HOW_TO_FIX_MSG);
    }
  }
}
 
Example #4
Source File: GenRepoInfoFileMojoTest.java    From app-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testExecute()
    throws MojoFailureException, MojoExecutionException, AppEngineException {
  genMojo.ignoreErrors = true;
  genMojo.execute();

  ArgumentCaptor<GenRepoInfoFileConfiguration> captor =
      ArgumentCaptor.forClass(GenRepoInfoFileConfiguration.class);
  verify(genMock).generate(captor.capture());
  Assert.assertEquals(genMojo.sourceDirectory.toPath(), captor.getValue().getSourceDirectory());
  Assert.assertEquals(genMojo.outputDirectory.toPath(), captor.getValue().getOutputDirectory());
}
 
Example #5
Source File: GenRepoInfoFileExtension.java    From app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
GenRepoInfoFileConfiguration toGenRepoInfoFileConfiguration() {
  return GenRepoInfoFileConfiguration.builder()
      .outputDirectory(NullSafe.convert(outputDirectory, File::toPath))
      .sourceDirectory(NullSafe.convert(outputDirectory, File::toPath))
      .build();
}