@Test public void tryHappyWrapper() throws IOException, MojoFailureException, MojoExecutionException { wrapper.execute(); }
@Override public void execute() throws MojoExecutionException, MojoFailureException { final String os_name = System.getProperty("os.name"); int windowsIndex = os_name.indexOf("indow"); if (inreleaseOS == null) { if (windowsIndex != -1) { inreleaseOS = "windows"; } else { inreleaseOS = "linux"; } } final File tf_dir = new File(".tf"); if (!tf_dir.exists()) { if (tf_dir.mkdir()) { getLog().info("Directory .tf is created"); } else { getLog().info("Failed to create directory .tf"); } } String[] tfwFileNames = {"tfw", "tfw.cmd", "tfw.ps1", "terraform-maven.properties"}; Path tfWrapperPath = Paths.get(".tf"); for (String tfwFileName : tfwFileNames) { File tfwFile = tfWrapperPath.resolve(tfwFileName).toFile(); if (!(tfwFileName.endsWith(".properties") && tfwFile.exists())) { try { FileUtils.copyURLToFile(this.getClass().getClassLoader().getResource("tf/" + tfwFileName), tfWrapperPath.resolve(tfwFileName).toFile()); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to create %s!", tfwFileName), e); } tfwFile.setExecutable(true); } } File propFile = new File(String.format(".tf%sterraform-maven.properties", File.separator)); Properties prop = new Properties(); prop.setProperty("releaseDir", ".tf"); try (InputStream fis = new FileInputStream(propFile)) { prop.load(fis); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to load properties from %s!", propFile.getName()), e); } if (indistributionSite != null) { prop.setProperty("distributionSite", indistributionSite); } if (inreleaseDir != null) { prop.setProperty("releaseDir", inreleaseDir); } if (inreleaseName != null) { prop.setProperty("releaseName", inreleaseName); } if (inreleaseVer != null) { prop.setProperty("releaseVer", inreleaseVer); } if (inreleaseOS != null) { prop.setProperty("releaseOS", inreleaseOS); } if (inreleaseSuffix != null) { prop.setProperty("releaseSuffix", inreleaseSuffix); } try (BufferedWriter propOut = new BufferedWriter(new FileWriter(propFile))) { Set<String> keys = prop.stringPropertyNames(); for (String key : keys) { propOut.write(key + "=" + prop.getProperty(key) + "\n"); } propOut.flush(); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to write properties to %s!", propFile.getName()), e); } }
Wrapper extends TerraformMojo<String> { @Override public void execute() throws MojoExecutionException, MojoFailureException { final String os_name = System.getProperty("os.name"); int windowsIndex = os_name.indexOf("indow"); if (inreleaseOS == null) { if (windowsIndex != -1) { inreleaseOS = "windows"; } else { inreleaseOS = "linux"; } } final File tf_dir = new File(".tf"); if (!tf_dir.exists()) { if (tf_dir.mkdir()) { getLog().info("Directory .tf is created"); } else { getLog().info("Failed to create directory .tf"); } } String[] tfwFileNames = {"tfw", "tfw.cmd", "tfw.ps1", "terraform-maven.properties"}; Path tfWrapperPath = Paths.get(".tf"); for (String tfwFileName : tfwFileNames) { File tfwFile = tfWrapperPath.resolve(tfwFileName).toFile(); if (!(tfwFileName.endsWith(".properties") && tfwFile.exists())) { try { FileUtils.copyURLToFile(this.getClass().getClassLoader().getResource("tf/" + tfwFileName), tfWrapperPath.resolve(tfwFileName).toFile()); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to create %s!", tfwFileName), e); } tfwFile.setExecutable(true); } } File propFile = new File(String.format(".tf%sterraform-maven.properties", File.separator)); Properties prop = new Properties(); prop.setProperty("releaseDir", ".tf"); try (InputStream fis = new FileInputStream(propFile)) { prop.load(fis); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to load properties from %s!", propFile.getName()), e); } if (indistributionSite != null) { prop.setProperty("distributionSite", indistributionSite); } if (inreleaseDir != null) { prop.setProperty("releaseDir", inreleaseDir); } if (inreleaseName != null) { prop.setProperty("releaseName", inreleaseName); } if (inreleaseVer != null) { prop.setProperty("releaseVer", inreleaseVer); } if (inreleaseOS != null) { prop.setProperty("releaseOS", inreleaseOS); } if (inreleaseSuffix != null) { prop.setProperty("releaseSuffix", inreleaseSuffix); } try (BufferedWriter propOut = new BufferedWriter(new FileWriter(propFile))) { Set<String> keys = prop.stringPropertyNames(); for (String key : keys) { propOut.write(key + "=" + prop.getProperty(key) + "\n"); } propOut.flush(); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to write properties to %s!", propFile.getName()), e); } } }
Wrapper extends TerraformMojo<String> { @Override public void execute() throws MojoExecutionException, MojoFailureException { final String os_name = System.getProperty("os.name"); int windowsIndex = os_name.indexOf("indow"); if (inreleaseOS == null) { if (windowsIndex != -1) { inreleaseOS = "windows"; } else { inreleaseOS = "linux"; } } final File tf_dir = new File(".tf"); if (!tf_dir.exists()) { if (tf_dir.mkdir()) { getLog().info("Directory .tf is created"); } else { getLog().info("Failed to create directory .tf"); } } String[] tfwFileNames = {"tfw", "tfw.cmd", "tfw.ps1", "terraform-maven.properties"}; Path tfWrapperPath = Paths.get(".tf"); for (String tfwFileName : tfwFileNames) { File tfwFile = tfWrapperPath.resolve(tfwFileName).toFile(); if (!(tfwFileName.endsWith(".properties") && tfwFile.exists())) { try { FileUtils.copyURLToFile(this.getClass().getClassLoader().getResource("tf/" + tfwFileName), tfWrapperPath.resolve(tfwFileName).toFile()); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to create %s!", tfwFileName), e); } tfwFile.setExecutable(true); } } File propFile = new File(String.format(".tf%sterraform-maven.properties", File.separator)); Properties prop = new Properties(); prop.setProperty("releaseDir", ".tf"); try (InputStream fis = new FileInputStream(propFile)) { prop.load(fis); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to load properties from %s!", propFile.getName()), e); } if (indistributionSite != null) { prop.setProperty("distributionSite", indistributionSite); } if (inreleaseDir != null) { prop.setProperty("releaseDir", inreleaseDir); } if (inreleaseName != null) { prop.setProperty("releaseName", inreleaseName); } if (inreleaseVer != null) { prop.setProperty("releaseVer", inreleaseVer); } if (inreleaseOS != null) { prop.setProperty("releaseOS", inreleaseOS); } if (inreleaseSuffix != null) { prop.setProperty("releaseSuffix", inreleaseSuffix); } try (BufferedWriter propOut = new BufferedWriter(new FileWriter(propFile))) { Set<String> keys = prop.stringPropertyNames(); for (String key : keys) { propOut.write(key + "=" + prop.getProperty(key) + "\n"); } propOut.flush(); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to write properties to %s!", propFile.getName()), e); } }  }
Wrapper extends TerraformMojo<String> { @Override public void execute() throws MojoExecutionException, MojoFailureException { final String os_name = System.getProperty("os.name"); int windowsIndex = os_name.indexOf("indow"); if (inreleaseOS == null) { if (windowsIndex != -1) { inreleaseOS = "windows"; } else { inreleaseOS = "linux"; } } final File tf_dir = new File(".tf"); if (!tf_dir.exists()) { if (tf_dir.mkdir()) { getLog().info("Directory .tf is created"); } else { getLog().info("Failed to create directory .tf"); } } String[] tfwFileNames = {"tfw", "tfw.cmd", "tfw.ps1", "terraform-maven.properties"}; Path tfWrapperPath = Paths.get(".tf"); for (String tfwFileName : tfwFileNames) { File tfwFile = tfWrapperPath.resolve(tfwFileName).toFile(); if (!(tfwFileName.endsWith(".properties") && tfwFile.exists())) { try { FileUtils.copyURLToFile(this.getClass().getClassLoader().getResource("tf/" + tfwFileName), tfWrapperPath.resolve(tfwFileName).toFile()); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to create %s!", tfwFileName), e); } tfwFile.setExecutable(true); } } File propFile = new File(String.format(".tf%sterraform-maven.properties", File.separator)); Properties prop = new Properties(); prop.setProperty("releaseDir", ".tf"); try (InputStream fis = new FileInputStream(propFile)) { prop.load(fis); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to load properties from %s!", propFile.getName()), e); } if (indistributionSite != null) { prop.setProperty("distributionSite", indistributionSite); } if (inreleaseDir != null) { prop.setProperty("releaseDir", inreleaseDir); } if (inreleaseName != null) { prop.setProperty("releaseName", inreleaseName); } if (inreleaseVer != null) { prop.setProperty("releaseVer", inreleaseVer); } if (inreleaseOS != null) { prop.setProperty("releaseOS", inreleaseOS); } if (inreleaseSuffix != null) { prop.setProperty("releaseSuffix", inreleaseSuffix); } try (BufferedWriter propOut = new BufferedWriter(new FileWriter(propFile))) { Set<String> keys = prop.stringPropertyNames(); for (String key : keys) { propOut.write(key + "=" + prop.getProperty(key) + "\n"); } propOut.flush(); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to write properties to %s!", propFile.getName()), e); } }  @Override void execute(); }
Wrapper extends TerraformMojo<String> { @Override public void execute() throws MojoExecutionException, MojoFailureException { final String os_name = System.getProperty("os.name"); int windowsIndex = os_name.indexOf("indow"); if (inreleaseOS == null) { if (windowsIndex != -1) { inreleaseOS = "windows"; } else { inreleaseOS = "linux"; } } final File tf_dir = new File(".tf"); if (!tf_dir.exists()) { if (tf_dir.mkdir()) { getLog().info("Directory .tf is created"); } else { getLog().info("Failed to create directory .tf"); } } String[] tfwFileNames = {"tfw", "tfw.cmd", "tfw.ps1", "terraform-maven.properties"}; Path tfWrapperPath = Paths.get(".tf"); for (String tfwFileName : tfwFileNames) { File tfwFile = tfWrapperPath.resolve(tfwFileName).toFile(); if (!(tfwFileName.endsWith(".properties") && tfwFile.exists())) { try { FileUtils.copyURLToFile(this.getClass().getClassLoader().getResource("tf/" + tfwFileName), tfWrapperPath.resolve(tfwFileName).toFile()); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to create %s!", tfwFileName), e); } tfwFile.setExecutable(true); } } File propFile = new File(String.format(".tf%sterraform-maven.properties", File.separator)); Properties prop = new Properties(); prop.setProperty("releaseDir", ".tf"); try (InputStream fis = new FileInputStream(propFile)) { prop.load(fis); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to load properties from %s!", propFile.getName()), e); } if (indistributionSite != null) { prop.setProperty("distributionSite", indistributionSite); } if (inreleaseDir != null) { prop.setProperty("releaseDir", inreleaseDir); } if (inreleaseName != null) { prop.setProperty("releaseName", inreleaseName); } if (inreleaseVer != null) { prop.setProperty("releaseVer", inreleaseVer); } if (inreleaseOS != null) { prop.setProperty("releaseOS", inreleaseOS); } if (inreleaseSuffix != null) { prop.setProperty("releaseSuffix", inreleaseSuffix); } try (BufferedWriter propOut = new BufferedWriter(new FileWriter(propFile))) { Set<String> keys = prop.stringPropertyNames(); for (String key : keys) { propOut.write(key + "=" + prop.getProperty(key) + "\n"); } propOut.flush(); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to write properties to %s!", propFile.getName()), e); } }  @Override void execute();  }