本文整理汇总了Java中org.eclipse.xtext.util.Files类的典型用法代码示例。如果您正苦于以下问题:Java Files类的具体用法?Java Files怎么用?Java Files使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Files类属于org.eclipse.xtext.util包,在下文中一共展示了Files类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: cleanUpTmpFolder
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
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
}
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:OnTheFlyJavaCompiler.java
示例2: generateCompileScript
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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);
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:30,代码来源:ScriptsBuilder.java
示例3: generateBuildScript
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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);
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:22,代码来源:ScriptsBuilder.java
示例4: generateTestScript
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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);
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:29,代码来源:ScriptsBuilder.java
示例5: generateTestDockerScript
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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);
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:29,代码来源:ScriptsBuilder.java
示例6: getClientAppJson
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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;
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:22,代码来源:JsonChecker.java
示例7: getServerAppJson
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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;
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:22,代码来源:JsonChecker.java
示例8: checkGenerateApp
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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;
}
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:24,代码来源:ResultChecker.java
示例9: checkCompileApp
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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;
}
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:23,代码来源:ResultChecker.java
示例10: checkBuildApp
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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;
}
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:21,代码来源:ResultChecker.java
示例11: extractCoverageIntstructions
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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;
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:27,代码来源:ResultChecker.java
示例12: extractCoverageBranches
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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;
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:25,代码来源:ResultChecker.java
示例13: extractJSCoverageStatements
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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;
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:22,代码来源:ResultChecker.java
示例14: extractJSCoverageBranches
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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;
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:22,代码来源:ResultChecker.java
示例15: extractStacktraces
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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;
}
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:31,代码来源:ResultChecker.java
示例16: getRoot
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
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);
}
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:MultiProjectTest.java
示例17: setup
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
@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);
}
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:23,代码来源:WorkspaceManagerTest.java
示例18: setup
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
@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);
}
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:25,代码来源:AbstractLanguageServerTest.java
示例19: main
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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);
}
开发者ID:eclipse,项目名称:xtext-core,代码行数:23,代码来源:CliWizardIntegrationTest.java
示例20: getRepoName
import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
* 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;
}
开发者ID:eclipse,项目名称:n4js,代码行数:46,代码来源:RepoRelativePath.java
注:本文中的org.eclipse.xtext.util.Files类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论