Archived
0

временно отложенные наработки

This commit is contained in:
2016-07-29 11:51:40 +03:00
parent a449bcc2b5
commit 0e1b6ac0bf
9 changed files with 134 additions and 7 deletions

View File

@@ -5,6 +5,7 @@
package asys.core;
import asys.core.api.ICore;
import org.apache.commons.io.FileUtils;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;

View File

@@ -9,13 +9,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -32,7 +30,11 @@ import java.util.zip.ZipInputStream;
public class BuildScript {
private Logger logger = LoggerFactory.getLogger(BuildScript.class);
List<String[]> scriptLines = new ArrayList<>();
private Map<String, String> variables;
private Map<String, String> variables = new HashMap<>();
public static BuildScript loadFromFile(File file) throws IOException, UnknowCommandException {
return new BuildScript(FileUtils.readFileToString(file, Charset.forName("UTF-8")));
}
public BuildScript(String script) throws UnknowCommandException {
if (script == null || script.trim().isEmpty()) {
@@ -54,6 +56,10 @@ public class BuildScript {
this.variables = variables;
}
public void setVariable(String name, String value) {
this.variables.put(name, value);
}
private String[] parseCommandLine(String line) throws UnknowCommandException {
final StringTokenizer strTok = new StringTokenizer(line, " \"\'", true);
final List<String> preArr = new ArrayList<>();
@@ -243,6 +249,7 @@ public class BuildScript {
ZipEntry ze;
while ((ze = zis.getNextEntry()) != null) {
if (ze.isDirectory()) continue;
String fileName = ze.getName();
File newFile = new File(targetPath.toFile(), fileName);
Files.createDirectories(Paths.get(newFile.getParent()));

View File

@@ -4,7 +4,7 @@
*/
package asys.core.buildscript;
class CommandException extends Exception {
public class CommandException extends Exception {
CommandException(String message) {
super(message);
}

View File

@@ -4,7 +4,7 @@
*/
package asys.core.buildscript;
class UnknowCommandException extends CommandException {
public class UnknowCommandException extends CommandException {
UnknowCommandException(String message) {
super(message);
}