423739 Start checks module files.

renamed option to --create-files
cleaned up logging and messages
removed switch statement.
This commit is contained in:
Greg Wilkins 2013-12-23 15:46:52 +11:00
parent 5380430b75
commit e5b85055bd
8 changed files with 21 additions and 73 deletions

View File

@ -3,35 +3,13 @@
# #
[files] [files]
${switch java.version http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.6.v20130911/npn-boot-1.1.6.v20130911.jar:lib/npn/npn-boot-1.1.6.v20130911.jar
1.7.0_9: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.3.v20130313/npn-boot-1.1.3.v20130313.jar:lib/npn/npn-boot-1.1.3.v20130313.jar
1.7.0_10: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.3.v20130313/npn-boot-1.1.3.v20130313.jar:lib/npn/npn-boot-1.1.3.v20130313.jar
1.7.0_11: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.3.v20130313/npn-boot-1.1.3.v20130313.jar:lib/npn/npn-boot-1.1.3.v20130313.jar
1.7.0_13: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.4.v20130313/npn-boot-1.1.4.v20130313.jar:lib/npn/npn-boot-1.1.4.v20130313.jar
1.7.0_15: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_17: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_21: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_25: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_40: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.6.v20130911/npn-boot-1.1.6.v20130911.jar:lib/npn/npn-boot-1.1.6.v20130911.jar
1.7.0_45: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.6.v20130911/npn-boot-1.1.6.v20130911.jar:lib/npn/npn-boot-1.1.6.v20130911.jar
*: http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.6.v20130911/npn-boot-1.1.6.v20130911.jar:lib/npn/npn-boot-1.1.6.v20130911.jar
}
[ini-template] [ini-template]
# NPN Configuration
# NPN boot jar for JRE 1.7.0_45
--exec --exec
${switch java.version -Xbootclasspath/p:lib/npn/npn-boot-1.1.6.v20130911.jar
1.7.0_9: -Xbootclasspath/p:lib/npn/npn-boot-1.1.3.v20130313.jar
1.7.0_10: -Xbootclasspath/p:lib/npn/npn-boot-1.1.3.v20130313.jar
1.7.0_11: -Xbootclasspath/p:lib/npn/npn-boot-1.1.3.v20130313.jar
1.7.0_13: -Xbootclasspath/p:lib/npn/npn-boot-1.1.4.v20130313.jar
1.7.0_15: -Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_17: -Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_21: -Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_25: -Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar
1.7.0_40: -Xbootclasspath/p:lib/npn/npn-boot-1.1.6.v20130911.jar
1.7.0_45: -Xbootclasspath/p:lib/npn/npn-boot-1.1.6.v20130911.jar
*: -Xbootclasspath/p:lib/npn/npn-boot-1.1.6.v20130911.jar
}
# For other versions of JRE, an appropriate npn-boot jar must be downloaded # For other versions of JRE, an appropriate npn-boot jar must be downloaded
# #

View File

@ -381,7 +381,7 @@ public class Main
return; return;
} }
source = short_start_ini; source = short_start_ini;
StartLog.warn("%-15s initialised in %s (appended)",name,source); StartLog.info("%-15s initialised in %s (appended)",name,source);
out = new PrintWriter(new FileWriter(start_ini,true)); out = new PrintWriter(new FileWriter(start_ini,true));
} }
else else
@ -403,7 +403,7 @@ public class Main
return; return;
} }
source = short_ini; source = short_ini;
StartLog.warn("%-15s initialised in %s (created)",name,source); StartLog.info("%-15s initialised in %s (created)",name,source);
out = new PrintWriter(ini); out = new PrintWriter(ini);
} }
@ -462,7 +462,7 @@ public class Main
{ {
if (!short_ini.equals(source)) if (!short_ini.equals(source))
{ {
StartLog.warn("%-15s enabled in %s",name,baseHome.toShortForm(source)); StartLog.info("%-15s enabled in %s",name,baseHome.toShortForm(source));
} }
} }
@ -673,9 +673,9 @@ public class Main
args.setRun(false); args.setRun(false);
String type=arg.location.endsWith("/")?"directory":"file"; String type=arg.location.endsWith("/")?"directory":"file";
if (arg.uri==null) if (arg.uri==null)
StartLog.warn("Required %s '%s' does not exist. Run with --create",type,baseHome.toShortForm(file)); StartLog.warn("Required %s '%s' does not exist. Run with --create-files to create",type,baseHome.toShortForm(file));
else else
StartLog.warn("Required %s '%s' not downloaded from %s. Run with --download",type,baseHome.toShortForm(file),arg.uri); StartLog.warn("Required %s '%s' not downloaded from %s. Run with --create-files to download",type,baseHome.toShortForm(file),arg.uri);
} }
} }

View File

@ -102,7 +102,7 @@ public class Module
/** List of sources that enabled this module */ /** List of sources that enabled this module */
private final Set<String> sources = new HashSet<>(); private final Set<String> sources = new HashSet<>();
public Module(File file) throws FileNotFoundException, IOException public Module(BaseHome basehome,File file) throws FileNotFoundException, IOException
{ {
this.file = file; this.file = file;
@ -111,7 +111,7 @@ public class Module
name = Pattern.compile(".mod$",Pattern.CASE_INSENSITIVE).matcher(name).replaceFirst(""); name = Pattern.compile(".mod$",Pattern.CASE_INSENSITIVE).matcher(name).replaceFirst("");
init(); init();
process(); process(basehome);
} }
public void addChildEdge(Module child) public void addChildEdge(Module child)
@ -245,13 +245,13 @@ public class Module
return enabled; return enabled;
} }
public void process() throws FileNotFoundException, IOException public void process(BaseHome basehome) throws FileNotFoundException, IOException
{ {
Pattern section = Pattern.compile("\\s*\\[([^]]*)\\]\\s*"); Pattern section = Pattern.compile("\\s*\\[([^]]*)\\]\\s*");
if (!FS.canReadFile(file)) if (!FS.canReadFile(file))
{ {
StartLog.debug("Skipping read of missing file: %s",file.getAbsolutePath()); StartLog.debug("Skipping read of missing file: %s",basehome.toShortForm(file));
return; return;
} }
@ -261,36 +261,9 @@ public class Module
{ {
String line; String line;
String sectionType = ""; String sectionType = "";
String caseTag = null;
boolean switched = false;
while ((line = buf.readLine()) != null) while ((line = buf.readLine()) != null)
{ {
line = line.trim(); line = line.trim();
if (caseTag!=null)
{
if ("}".equals(line))
{
caseTag=null;
continue;
}
if (switched)
continue;
if (!line.startsWith(caseTag) && !line.startsWith("*:"))
continue;
switched=true;
line=line.substring(line.indexOf(':')+1).trim();
}
else if (line.startsWith("${switch "))
{
switched=false;
caseTag=line.substring(9).trim();
caseTag=System.getProperty(caseTag)+":";
continue;
}
Matcher sectionMatcher = section.matcher(line); Matcher sectionMatcher = section.matcher(line);
@ -300,7 +273,7 @@ public class Module
} }
else else
{ {
// blank lines and comments are valid for initialize section // blank lines and comments are valid for initialise section
if (line.length() == 0 || line.startsWith("#")) if (line.length() == 0 || line.startsWith("#"))
{ {
if ("INI-TEMPLATE".equals(sectionType)) if ("INI-TEMPLATE".equals(sectionType))

View File

@ -309,7 +309,7 @@ public class Modules implements Iterable<Module>
{ {
for (File file : basehome.listFiles("modules",new FS.FilenameRegexFilter("^.*\\.mod$"))) for (File file : basehome.listFiles("modules",new FS.FilenameRegexFilter("^.*\\.mod$")))
{ {
register(new Module(file)); register(new Module(basehome,file));
} }
} }

View File

@ -666,7 +666,7 @@ public class StartArgs
return; return;
} }
if (arg.equals("--download") || arg.equals("--create")) if (arg.equals("--create-files"))
{ {
run=false; run=false;
download=true; download=true;

View File

@ -60,7 +60,7 @@ public class StartLog
public static void info(String format, Object... args) public static void info(String format, Object... args)
{ {
System.err.printf("WARNING: " + format + "%n",args); System.err.printf("INFO: " + format + "%n",args);
} }
public static void warn(String format, Object... args) public static void warn(String format, Object... args)

View File

@ -94,12 +94,9 @@ Module Management:
See http://graphviz.org/ for details on how to post-process See http://graphviz.org/ for details on how to post-process
this file into the output best suited for your needs. this file into the output best suited for your needs.
--download Download or create any missing files/directories that are --create-files Create any missing files that are required by initialised
required by initialised modules. modules. This may download a file from the network if the
module provides a URL.
--create Download or create any missing files/directories that are
required by initialised modules.
Startup / Shutdown Command Line: Startup / Shutdown Command Line:
-------------------------------- --------------------------------

View File

@ -34,7 +34,7 @@ public class ModuleTest
private Module loadTestHomeModule(String moduleFileName) throws IOException private Module loadTestHomeModule(String moduleFileName) throws IOException
{ {
File file = MavenTestingUtils.getTestResourceFile("usecases/home/modules/" + moduleFileName); File file = MavenTestingUtils.getTestResourceFile("usecases/home/modules/" + moduleFileName);
return new Module(file); return new Module(new BaseHome(),file);
} }
@Test @Test