Java 类org.eclipse.xtext.util.Files 实例源码

项目:xtext-extras    文件:OnTheFlyJavaCompiler.java   
protected void cleanUpTmpFolder(File tempDir) {
    if (temporaryFolder == null || !temporaryFolder.isInitialized()) {
        try {
            tempDir.deleteOnExit();
            // Classloader needs .class files to lazy load an anonymous non static classes
            Files.cleanFolder(tempDir, new FileFilter() {
                @Override
                public boolean accept(File pathname) {
                    boolean isClass = pathname.getName().endsWith(".class");
                    if(isClass) {
                        pathname.deleteOnExit();
                    }
                    return !isClass;
                }
            }, true, true);
        } catch (FileNotFoundException e) {
            // ignore
        }
    }
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
/**
 * Generate the script to compile the JHipster application.
 * 
 * @param jconf Configuration of JHipster
 * @param jDirectory Directory where the script must be generated
 */
private void generateCompileScript(JhipsterConfiguration jconf, String jDirectory){
    String script = "#!/bin/bash\n\n";

    switch (jconf.prodDatabaseType){
    case "mysql":   script += getMysqlScript();
    break;
    case "mongodb": script += getMongodbScript();
    break;
    case "cassandra":   script += getCassandraScript();
    break;
    case "postgresql":  script += getPostgreScript();
    break;
    case "mariadb": script += getMysqlScript();
    break;
    }


    if(jconf.buildTool.equals("maven")) script+= "mvn compile";
    else script+="./gradlew compileJava";

    script += ">> compile.log 2>&1";
    Files.writeStringIntoFile(getjDirectory(jDirectory)+"compile.sh", script);
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
/**
 * Generate the script to build the application without the use of Docker.
 * 
 * @param jconf JHipster configuration to build.
 * @param jDirectory Directory where the script must be generated.
 */
private void generateBuildScript(JhipsterConfiguration jconf, String jDirectory){
    String script = "#!/bin/bash\n\n";  

    // TODO See if we include dev profile for all variants
    if(jconf.devDatabaseType.startsWith("h2")){
        if(jconf.buildTool.equals("maven")) script += "./mvnw -Pdev ";
        else script += "./gradlew -Pdev ";
    } else{
        if(jconf.buildTool.equals("maven")) script += "./mvnw -Pprod ";
        else script += "./gradlew -Pprod ";
    }

    script += ">> build.log 2>&1";
    Files.writeStringIntoFile(getjDirectory(jDirectory) + "build.sh", script);
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
/**
 * Generate script used to run tests on the configuration and write it in test.sh.
 * 
 * @param jconf Configuration on which tests are run.
 * @param jDirectory Directory where to write the script.
 */
private void generateTestScript(JhipsterConfiguration jconf, String jDirectory){
    String script = "#!/bin/bash\n\n";
    Properties properties = getProperties(PROPERTIES_FILE);

    for(String testFramework : jconf.testFrameworks){
        switch(testFramework){
        case "gatling":     script += properties.getProperty("removeGatlingSimulations");
                            if(jconf.buildTool.equals("maven"))
                                script += "./mvnw gatling:execute";
                            else
                                script += "printf 'empadlew gatlingRun -x cleanResources";
                            script += " >> testGatling.log 2>&1\n";
                            break;
        case "protractor":  script += "xvfb-run gulp protractor >> testProtractor.log 2>&1\n";
                            break;
        case "cucumber":    if (jconf.buildTool.equals("maven")) script += "./mvnw test >> cucumber.log 2>&1\n";
                            else script += "./gradlew test >> cucumber.log 2>&1\n";
        break;
        }
    }
    Files.writeStringIntoFile(getjDirectory(jDirectory)+"test.sh", script);
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
/**
 * Generate script used to run tests on the configuration and write it in testDocker.sh.
 * 
 * @param jconf Configuration on which tests are run.
 * @param jDirectory Directory where to write the script.
 */
private void generateTestDockerScript(JhipsterConfiguration jconf, String jDirectory){
    String script = "#!/bin/bash\n\n";
    Properties properties = getProperties(PROPERTIES_FILE);

    for(String testFramework : jconf.testFrameworks){
        switch(testFramework){
            case "gatling": script += properties.getProperty("removeGatlingSimulations");
                            if(jconf.buildTool.equals("maven"))
                                script += "./mvnw gatling:execute";
                            else
                                script += "printf 'empadlew gatlingRun -x cleanResources";
                            script += " >> testDockerGatling.log 2>&1\n";
                            break;
        case "protractor":  script += "xvfb-run gulp protractor >> testDockerProtractor.log 2>&1\n";
        break;
        case "cucumber":    if (jconf.buildTool.equals("maven")) script += "./mvnw test >> cucumberDocker.log 2>&1\n";
        else script += "./gradlew test >> cucumberDocker.log 2>&1\n";
        break;
        }
    }
    Files.writeStringIntoFile(getjDirectory(jDirectory)+"testDocker.sh", script);
}
项目:Thesis-JHipster    文件:JsonChecker.java   
/**
 * Returns all yo-rc.json templates related to the clientApp.
 * All these templates must be located in: yo-rc-templates/ and start with clientApp
 * 
 * @return yo-rc.json Templates as JsonObject
 */
public JsonObject[] getClientAppJson(){
    int i = 0;
    JsonParser jsonParser = new JsonParser();
    if (clientAppJson == null){
        clientAppJson = new JsonObject[2];
        for(final File file:new File(YO_RC_DIRECTORY).listFiles()){
            if(file.getName().startsWith("clientApp")){ 
                JsonObject object = jsonParser.parse(Files.readFileIntoString(YO_RC_DIRECTORY+file.getName())).getAsJsonObject();
                clientAppJson[i] = object;
                i++;
            }
        }
    }
    return clientAppJson;
}
项目:Thesis-JHipster    文件:JsonChecker.java   
/**
 * Returns all yo-rc.json templates related to the serverApp.
 * All these templates must be located in: yo-rc-templates/ and start with serverApp 
 * 
 * @return
 */
public JsonObject[] getServerAppJson(){
    int i = 0;
    JsonParser jsonParser = new JsonParser();
    if(serverAppJson == null){
        serverAppJson = new JsonObject[4];
        for(final File file:new File(YO_RC_DIRECTORY).listFiles()){
            if(file.getName().startsWith("serverApp")){
                JsonObject object= jsonParser.parse(Files.readFileIntoString(YO_RC_DIRECTORY+file.getName())).getAsJsonObject();
                serverAppJson[i] = object;
                i++;
            }
        }
    }
    return serverAppJson;
}
项目:Thesis-JHipster    文件:ResultChecker.java   
/**
 * Check the App is generated successfully
 * 
 * @param file Name to check
 * @return true if the app is well generated
 */
public boolean checkGenerateApp(String fileName){

    try{
    //extract log
    String text = Files.readFileIntoString(path +fileName);

    //CHECK IF Server app generated successfully.
    //OR Client app generated successfully.
    Matcher m = Pattern.compile("((.*?)Server app generated successfully.)").matcher(text);
    Matcher m2 = Pattern.compile("((.*?)Client app generated successfully.)").matcher(text);

    while(m.find() | m2.find()) return true; 
    return false;
    } catch (Exception e){
        return false;
    }
}
项目:Thesis-JHipster    文件:ResultChecker.java   
/**
 * Check the App is compiled successfully
 * 
 * @param file Name to check
 * @return true if the app is well compiled
 */
public boolean checkCompileApp(String fileName) throws FileNotFoundException{

    try{
    //extract log
    String text = Files.readFileIntoString(path + fileName);

    //CHECK IF BUILD FAILED THEN false
    Matcher m1 = Pattern.compile("((.*?)BUILD FAILED)").matcher(text);
    Matcher m2 = Pattern.compile("((.*?)BUILD FAILURE)").matcher(text);

    while(m1.find() | m2.find()) return false;
    return true;
    } catch (Exception e){
        return false;
    }
}
项目:Thesis-JHipster    文件:ResultChecker.java   
/**
 * Check the App is build successfully
 * 
 * @param jDirectory Name of the folder
 */
public boolean checkBuildApp(String fileName){
    try{
        String text = Files.readFileIntoString(path+fileName);

        //CHECK IF BUILD FAILED THEN false
        Matcher m = Pattern.compile("((.*?)APPLICATION FAILED TO START)").matcher(text);
        Matcher m2 = Pattern.compile("((.*?)BUILD FAILED)").matcher(text);
        Matcher m3 = Pattern.compile("((.*?)BUILD FAILURE)").matcher(text);

        while(m.find() | m2.find() | m3.find()) return false;
        return true;
    } catch (Exception e){
        return false;
    }
}
项目:Thesis-JHipster    文件:ResultChecker.java   
/**
 * Return coverageInstructions from Jacoco
 * 
 * @param jDirectory Name of the folder
 * @return String coverage of instructions
 * 
 */
public String extractCoverageIntstructions(String fileName){
    String resultsTests = DEFAULT_NOT_FOUND_VALUE;
    try{
        _log.info("ça passe !");
        String text = Files.readFileIntoString(path+JACOCOPATH+fileName);

        Matcher m1 = Pattern.compile("Total</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?) %"
                + "</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?) %</td>").matcher(text);

        Matcher m2 = Pattern.compile("Total</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?)%"
                + "</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?)%</td>").matcher(text);

        while(m1.find()) return resultsTests = m1.group(2).toString();
        while(m2.find()) return resultsTests = m2.group(2).toString();
    } catch (Exception e){
        _log.error("Exception: "+e.getMessage());
    }
    return resultsTests;
}
项目:Thesis-JHipster    文件:ResultChecker.java   
/**
 * Return coverageBranches from Jacoco
 * 
 * @param jDirectory Name of the folder
 * @return String coverage of Branches
 * 
 */
public String extractCoverageBranches(String fileName){
    String resultsTests = DEFAULT_NOT_FOUND_VALUE;
    try{
        String text = Files.readFileIntoString(path+JACOCOPATH+fileName);

        Matcher m1 = Pattern.compile("Total</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?) %"
                + "</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?) %</td>").matcher(text);
        Matcher m2 = Pattern.compile("Total</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?)%"
                + "</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?)%</td>").matcher(text);

        while(m1.find()) return resultsTests = m1.group(4).toString();
        while(m2.find()) return resultsTests = m2.group(4).toString();
    } catch (Exception e){
        _log.error("Exception: "+e.getMessage());
    }
    return resultsTests;
}
项目:Thesis-JHipster    文件:ResultChecker.java   
/**
 * Retrieves the percentage of Javascript Statements Coverage
 * 
 * @param fileName File containing the percentage. 
 * @return The percentage of Statement Coverage (Javascript)
 */
public String extractJSCoverageStatements(String fileName){
    String result = DEFAULT_NOT_FOUND_VALUE;
    try{
        String text = Files.readFileIntoString(path+fileName);
        Matcher m1 = Pattern.compile("(.*?)<div class='fl pad1y space-right2'>(\r*?)(\n*?)"
                                    + "(.*?)<span class=\"strong\">(.*?)</span>(\r*?)(\n*?)"
                                    + "(.*?)<span class=\"quiet\">Statements</span>(\r*?)(\n*?)"
                                    + "(.*?)<span class='fraction'>(.*?)</span>(\r*?)(\n*?)"
                                    + "(.*?)</div>").matcher(text);
        while(m1.find()) return m1.group(5).toString();
    } catch(Exception e){
        _log.error("Exception: "+e.getMessage());
    }
    return result;
}
项目:Thesis-JHipster    文件:ResultChecker.java   
/**
 * Retrieves the percentage of Javascript Branches Coverage
 * 
 * @param fileName File containing the percentage.
 * @return The percentage of Branches Coverage (Javascript)
 */
public String extractJSCoverageBranches(String fileName){
    String result = DEFAULT_NOT_FOUND_VALUE;
    try{
        String text = Files.readFileIntoString(path+fileName);
        Matcher m1 = Pattern.compile("(.*?)<div class='fl pad1y space-right2'>(\r*?)(\n*?)"
                                    + "(.*?)<span class=\"strong\">(.*?)</span>(\r*?)(\n*?)"
                                    + "(.*?)<span class=\"quiet\">Branches</span>(\r*?)(\n*?)"
                                    + "(.*?)<span class='fraction'>(.*?)</span>(\r*?)(\n*?)"
                                    + "(.*?)</div>").matcher(text);
        while(m1.find()) return m1.group(5).toString();
    } catch(Exception e){
        _log.error("Exception: "+e.getMessage());
    }
    return result;
}
项目:Thesis-JHipster    文件:ResultChecker.java   
/**
 * Return stacktraces
 * 
 * @param jDirectory Name of the folder
 * @return String of stacktraces
 * 
 */
public String extractStacktraces(String fileName){
    String stacktraces = "";
    try{        
        String text = Files.readFileIntoString(path+fileName);

        Matcher m1 = Pattern.compile("(Exception(.*?)\\n)").matcher(text);
        Matcher m2 = Pattern.compile("(Caused by(.*?)\\n)").matcher(text);
        Matcher m3 = Pattern.compile("((.*?)\\[ERROR\\](.*))").matcher(text);
        Matcher m4 = Pattern.compile("(ERROR:(.*?)\\n)").matcher(text);
        Matcher m5 = Pattern.compile("(error:(.*?)^)").matcher(text);
        Matcher m6 = Pattern.compile("(Error parsing reference:(.*?) is not a valid repository/tag)").matcher(text);

        while(m1.find()) stacktraces = stacktraces + m1.group().toString() + "\n";
        while(m2.find()) stacktraces = stacktraces + m2.group().toString() + "\n";
        while(m3.find()) stacktraces = stacktraces + m3.group().toString() + "\n";
        while(m4.find()) stacktraces = stacktraces + m4.group().toString() + "\n";
        while(m5.find()) stacktraces = stacktraces + m5.group().toString() + "\n";
        while(m6.find()) stacktraces = stacktraces + m6.group(1).toString() + "\n";
    } catch (Exception e){
        _log.error("Exception: "+e.getMessage());
    }
    return stacktraces;
}
项目:xtext-core    文件:MultiProjectTest.java   
protected File getRoot(final String path) {
  try {
    File _xblockexpression = null;
    {
      final File root = new File(path);
      boolean _mkdirs = root.mkdirs();
      boolean _not = (!_mkdirs);
      if (_not) {
        Files.cleanFolder(root, null, true, false);
      }
      root.deleteOnExit();
      _xblockexpression = root;
    }
    return _xblockexpression;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:xtext-core    文件:WorkspaceManagerTest.java   
@Before
public void setup() {
  try {
    ServerModule _serverModule = new ServerModule();
    final Injector injector = Guice.createInjector(_serverModule);
    injector.injectMembers(this);
    File _file = new File("./test-data/test-project");
    this.root = _file;
    boolean _mkdirs = this.root.mkdirs();
    boolean _not = (!_mkdirs);
    if (_not) {
      Files.cleanFolder(this.root, null, true, false);
    }
    this.root.deleteOnExit();
    final Procedure2<URI, Iterable<Issue>> _function = (URI $0, Iterable<Issue> $1) -> {
      this.diagnostics.put($0, IterableExtensions.<Issue>toList($1));
    };
    this.workspaceManger.initialize(this.uriExtensions.withEmptyAuthority(URI.createFileURI(this.root.getAbsolutePath())), _function, null);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:xtext-core    文件:AbstractLanguageServerTest.java   
@Before
public void setup() {
  try {
    final Injector injector = Guice.createInjector(this.getServerModule());
    injector.injectMembers(this);
    final Object resourceServiceProvider = this.resourceServerProviderRegistry.getExtensionToFactoryMap().get(this.fileExtension);
    if ((resourceServiceProvider instanceof IResourceServiceProvider)) {
      this.languageInfo = ((IResourceServiceProvider)resourceServiceProvider).<LanguageInfo>get(LanguageInfo.class);
    }
    this.languageServer.connect(ServiceEndpoints.<LanguageClientExtensions>toServiceObject(this, LanguageClientExtensions.class));
    this.languageServer.supportedMethods();
    File _absoluteFile = new File("").getAbsoluteFile();
    File _file = new File(_absoluteFile, "/test-data/test-project");
    this.root = _file;
    boolean _mkdirs = this.root.mkdirs();
    boolean _not = (!_mkdirs);
    if (_not) {
      Files.cleanFolder(this.root, null, true, false);
    }
    this.root.deleteOnExit();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
项目:xtext-core    文件:CliWizardIntegrationTest.java   
/**
 * Use this main method to update the expectations to whatever the wizard currently generates
 */
public static void main(final String[] args) {
  final CliProjectsCreator creator = CliWizardIntegrationTest.newProjectCreator();
  final Consumer<WizardConfiguration> _function = (WizardConfiguration config) -> {
    try {
      String _baseName = config.getBaseName();
      final File targetLocation = new File("testdata/wizard-expectations", _baseName);
      targetLocation.mkdirs();
      Files.sweepFolder(targetLocation);
      config.setRootLocation(targetLocation.getPath());
      creator.createProjects(config);
      String _baseName_1 = config.getBaseName();
      String _plus = ("Updating expectations for " + _baseName_1);
      InputOutput.<String>println(_plus);
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
  };
  CliWizardIntegrationTest.projectConfigs.forEach(_function);
}
项目:n4js    文件:RepoRelativePath.java   
/**
 * Tries to obtain repository name from the provided directory by reading git config in
 * {@code currendDir/.git/config}
 *
 * @return string with repo name or {@code null}
 */
private static String getRepoName(File currentDir) {
    File gitFolder = new File(currentDir, ".git");
    if (!gitFolder.isDirectory()) {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("No '.git' folder at " + currentDir.getAbsolutePath());
        return null;
    }

    File config = new File(gitFolder, "config");
    if (!config.isFile()) {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("No 'config' file at " + gitFolder.getAbsolutePath());
        return null;
    }
    try {
        String configStr = Files.readFileIntoString(config.getAbsolutePath());
        Config cfg = new Config();

        cfg.fromText(configStr);
        String originURL = cfg.getString("remote", "origin", "url");
        if (originURL != null && !originURL.isEmpty()) {
            int lastSlash = originURL.lastIndexOf('/');
            String repoName = null;
            if (lastSlash >= 0) {
                repoName = originURL.substring(lastSlash + 1);
            } else {
                repoName = originURL;
            }
            if (repoName.endsWith(".git")) {
                repoName = repoName.substring(0, repoName.length() - 4);
            }
            return repoName;
        }
    } catch (ConfigInvalidException e) {
        LOGGER.warn("Cannot read git config at " + config.getAbsolutePath(), e);
    }

    return null;
}
项目:xtext-extras    文件:OnTheFlyJavaCompiler.java   
protected File createTempDir() {
    if (temporaryFolder != null && temporaryFolder.isInitialized()) {
        try {
            return temporaryFolder.newFolder();
        } catch (IOException e) {
            throw new RuntimeIOException(e);
        }
    }
    return com.google.common.io.Files.createTempDir();
}
项目:xtext-extras    文件:CompilationTestHelper.java   
/**
 * Physically copies the given files to the currently used workspace root (a temporary folder).
 * @param workspacefilePath the workspace relative path
 * @param contents the file contents
 */
public URI copyToWorkspace(String workspacefilePath, CharSequence contents) {
    File fullPath = new File(workspaceRoot.getAbsolutePath()+"/"+workspacefilePath);
    if (fullPath.exists()) {
        fullPath.delete();
    } else {
        mkDir(fullPath.getParentFile());
    }
    URI uri = URI.createFileURI(fullPath.getAbsolutePath());
    Files.writeStringIntoFile(uri.toFileString(), contents.toString());
    return uri;
}
项目:xtext-extras    文件:StandaloneBuilderTest.java   
@After
public void cleanup() throws IOException {
    deleteFolder("src-gen");
    deleteFolder("src2-gen");
    if (TMP_DIR.exists()) {
        Files.sweepFolder(TMP_DIR);
        TMP_DIR.delete();
    }
}
项目:xtext-extras    文件:StandaloneBuilderTest.java   
private void deleteFolder(String projectRelativePath) throws FileNotFoundException {
    File folder = getFile(projectRelativePath);
    if (folder.exists()) {
        Files.sweepFolder(folder);
        folder.delete();
    }
}
项目:xtext-extras    文件:TestEclipseCompiler.java   
@After
public void tearDown() throws FileNotFoundException {
    if (outputClassDirectory != null && outputClassDirectory.exists()) {
        assertTrue("Unable to delete test directory: " + outputClassDirectory.getAbsolutePath(),
                Files.sweepFolder(outputClassDirectory));
    }
}
项目:xtext-extras    文件:GeneratorUtil.java   
public static void cleanFolder(String srcGenPath) throws FileNotFoundException {
    File f = new File(srcGenPath);
    if (!f.exists())
        throw new FileNotFoundException(srcGenPath + " " + f.getAbsolutePath());
    log.info("Cleaning folder " + f.getPath());
    Files.cleanFolder(f, new FileFilter() {
        private final Collection<String> excludes = new HashSet<String>(Arrays.asList(defaultExcludes));
        @Override
        public boolean accept(File pathname) {
            return !excludes.contains(pathname.getName());
        }
    }, false, false);
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
/**
 * Generate the script to stop all databases services.
 * 
 * @param jDirectory Directory where the script must be generated.
 */
public void generateStopDatabaseScript(String jDirectory){
    Properties property = getProperties(PROPERTIES_FILE);
    String script = "#!/bin/bash\n\n"
            + property.getProperty("mysqlStop")
            + property.getProperty("cassandraStop")
            + property.getProperty("mongodbStop")
            + property.getProperty("postgreStop");

    Files.writeStringIntoFile(jDirectory+"/stopDB.sh", script);
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
/**
 * Generates the script to generate the JHipster application.\n
 * This script varies depending on the application type (see JHipster's Sub-Generators)
 * 
 * @param jconf JHipster Configuration to generate;
 * @param jDirectory Name of the directory (jhipster+id) in which the script will be placed.
 */
private void generateYoJhipsterScript(JhipsterConfiguration jconf, String jDirectory){
    String script = "#!/bin/bash\n\n";

    if(jconf.applicationType.equals("clientApp")) script += "yo jhipster:client --auth session ";
    else if (jconf.applicationType.equals("serverApp")) script += "yo jhipster:server ";
    else script += "yo jhipster ";

    script += ">> generate.log 2>&1\n";

    Files.writeStringIntoFile(getjDirectory(jDirectory) + "generate.sh", script);
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
/**
 * Generate the script to run the unit test(s) of the application.
 * 
 * @param jconf JHipster configuration to test
 * @param jDirectory Directory where the script must be generated
 */
private void generateUnitTestScript(JhipsterConfiguration jconf, String jDirectory){
    String script = "#!/bin/bash\n\n";
    if (jconf.buildTool.equals("maven")) script += "./mvnw test >> test.log 2>&1\n";
    else script += "./gradlew test >> test.log 2>&1\n";
    // KarmaJS is provided by default
    script += "gulp test >> testKarmaJS.log 2>&1\n";
    Files.writeStringIntoFile(getjDirectory(jDirectory)+"unitTest.sh", script);
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
/**
 * Generate the script used to package and deploy an application via Docker.
 * 
 * @param jDirectory Directory where the script must be generated.
 * @param maven True if the application uses Maven; False otherwise.
 */
private void generateDockerStartScript(String jDirectory, JhipsterConfiguration jconf){
    Properties properties = getProperties(PROPERTIES_FILE);
    String script = "#!/bin/bash\n\n";
    if(jconf.databaseType.equals("cassandra")) script += properties.getProperty("cassandraMigration")+" >> cassandraMigration.log 2>&1";
    // Packaging
    if(jconf.buildTool.equals("maven")) script += properties.getProperty("mavenDockerPackage");
    else script += properties.getProperty("gradleDockerPackage");
    script+= " >> buildDocker.log 2>&1\n";
    // Docker-compose
    script += properties.getProperty("dockerStart")
            + " >> buildDocker.log 2>&1\n";

    Files.writeStringIntoFile(getjDirectory(jDirectory)+"dockerStart.sh", script);
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
private void generateDockerRetryScript(String jDirectory, JhipsterConfiguration jconf){
    Properties properties = getProperties(PROPERTIES_FILE);
    String script = "#!/bin/bash\n\n";
    // Docker-compose
    script += properties.getProperty("dockerStart")
            + " >> buildDocker2.log 2>&1\n";

    Files.writeStringIntoFile(getjDirectory(jDirectory)+"dockerRetry.sh", script);
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
/**
 * Generate the script used to stop the application via Docker and to remove all containers/images.
 * 
 * @param jconf JHipster configuration
 * @param jDirectory Directory where the script must be generated.
 */
private void generateDockerStopScript(JhipsterConfiguration jconf, String jDirectory){
    Properties properties = getProperties(PROPERTIES_FILE);
    // Stop main container
    String script = "#!/bin/bash\n\n"
            + properties.getProperty("dockerStop")
            + " >> dockerStop.log 2>&1\n";
    // Stop database container
    switch (jconf.prodDatabaseType){
    case "mysql":   script += properties.getProperty("dockerStopMysql");
    break;
    case "mongodb": script += properties.getProperty("dockerStopMongo");
    break;
    case "cassandra":   script += properties.getProperty("dockerStopCassandra");
    break;
    case "postgresql":  script += properties.getProperty("dockerStopPostgre");
    break;
    case "mariadb":     script += properties.getProperty("dockerStopMaria");
    break;
    }
    script += " >> dockerStop.log 2>&1\n";
    // Remove all Docker images
    script += properties.getProperty("dockerRemoveAll") + " >> dockerStop.log 2>&1\n";
    script += properties.getProperty("dockerRemoveImages") + " >> dockerStop.log 2>&1\n";

    Files.writeStringIntoFile(getjDirectory(jDirectory)+"dockerStop.sh", script);
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
/**
 * Generates a script to kill the server running on port 8080 into killScript.sh.
 * 
 * @param jDirectory Directory where to write the script.
 */
private void generateKillScript(String jDirectory){
    String script = "#!/bin/bash\n\n";
    Properties properties = getProperties(PROPERTIES_FILE);

    script += properties.getProperty("killApp")+"\n";
    script += properties.getProperty("killRegistry")+"\n";
    script += properties.getProperty("killUAA")+"\n";
    Files.writeStringIntoFile(getjDirectory(jDirectory)+"killScript.sh", script);
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
public void generatePublishScript(String jDirectory){
    String script = "#!/bin/bash\n\n";

    script += "tar acf "+jDirectory+".tar.gz *.log\n";
    script += "gdrive upload "+jDirectory+".tar.gz";

    Files.writeStringIntoFile(getjDirectory(jDirectory)+"publish.sh", script);
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
private void generateEntitiesScript(String jDirectory, String database){
    String script = "#!/bin/bash\n\n";
    Properties properties = getProperties(PROPERTIES_FILE);

    if(database.equals("mysql") || database.equals("postgresql") || database.equals("mariadb"))
        script += properties.getProperty("importJDL")+"\n";
    else if(database.equals("mongodb"))
        script += properties.getProperty("importJDLMongo")+"\n";
    else script += properties.getProperty("importJDLCassandra")+"\n";
    script += properties.getProperty("generateJDL")+" >> generateJDL.log 2>&1\n";
    Files.writeStringIntoFile(getjDirectory(jDirectory)+"generateJDL.sh", script);
}
项目:Thesis-JHipster    文件:ScriptsBuilder.java   
private void generateOracleDatabaseScript(JhipsterConfiguration jconf, String jDirectory){
    String script = "#!/bin/bash\n\n";
    Properties properties = getProperties(PROPERTIES_FILE);

    if(jconf.prodDatabaseType.equals("oracle")|jconf.devDatabaseType.equals("oracle"))
    {script += properties.getProperty("oracleInitJar")+"\n";
    Files.writeStringIntoFile(getjDirectory(jDirectory)+"oracleCopyJAR.sh", script);
    }
}
项目:Thesis-JHipster    文件:JsonChecker.java   
public JsonObject[] getUaaJson(){
    int i = 0;
    JsonParser jsonParser = new JsonParser();
    if (uaa == null){
        uaa = new JsonObject[2];
        for (final File file:new File(YO_RC_DIRECTORY).listFiles()){
            if(file.getName().startsWith("uaa")){
                JsonObject object = jsonParser.parse(Files.readFileIntoString(YO_RC_DIRECTORY+file.getName())).getAsJsonObject();
                uaa[i] = object;
                i++;
            }
        }
    }
    return uaa;
}
项目:Thesis-JHipster    文件:JsonChecker.java   
public JsonObject[] getMonolithJson(){
    int i = 0;
    JsonParser jsonParser = new JsonParser();
    if(monolith == null){
        monolith = new JsonObject[4];
        for(final File file:new File(YO_RC_DIRECTORY).listFiles()){
            if (file.getName().startsWith("monolith")){
                JsonObject object = jsonParser.parse(Files.readFileIntoString(YO_RC_DIRECTORY+file.getName())).getAsJsonObject();
                monolith[i] = object;
                i++;
            }
        }
    }
    return monolith;
}
项目:Thesis-JHipster    文件:JsonChecker.java   
public JsonObject[] getGatewayJson(){
    int i = 0;
    JsonParser jsonParser = new JsonParser();
    if(gateway == null){
        gateway = new JsonObject[4];
        for(final File file:new File(YO_RC_DIRECTORY).listFiles()){
            if(file.getName().startsWith("gateway")){
                JsonObject object = jsonParser.parse(Files.readFileIntoString(YO_RC_DIRECTORY+file.getName())).getAsJsonObject();
                gateway[i] = object;
                i++;
            }
        }
    }
    return gateway;
}
项目:Thesis-JHipster    文件:JsonChecker.java   
public JsonObject[] getMicroserviceJson(){
    int i = 0;
    JsonParser jsonParser = new JsonParser();
    if (microservice == null){
        microservice = new JsonObject[4];
        for(final File file:new File(YO_RC_DIRECTORY).listFiles()){
            if (file.getName().startsWith("microservice")){
                JsonObject object = jsonParser.parse(Files.readFileIntoString(YO_RC_DIRECTORY+file.getName())).getAsJsonObject();
                microservice[i] = object;
                i++;
            }
        }
    }
    return microservice;
}