Issue #984 Improve module listing
Transient modules only created in ini if directly added improved list-modules
This commit is contained in:
parent
d8b1c88abc
commit
33b290c8b2
|
@ -329,7 +329,7 @@
|
|||
<arguments>
|
||||
<argument>jetty.home=${assembly-directory}</argument>
|
||||
<argument>jetty.base=${assembly-directory}</argument>
|
||||
<argument>--add-to-start=deploy,websocket,ext,resources,jsp,jstl,http</argument>
|
||||
<argument>--add-to-start=server,deploy,websocket,ext,resources,jsp,jstl,http</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
<goals>
|
||||
|
|
|
@ -50,11 +50,10 @@ public class BaseBuilder
|
|||
*
|
||||
* @param module
|
||||
* the module to add
|
||||
* @return true if module was added, false if module was not added
|
||||
* (because that module already exists)
|
||||
* @return The ini file if module was added, null if module was not added.
|
||||
* @throws IOException if unable to add the module
|
||||
*/
|
||||
public boolean addModule(Module module) throws IOException;
|
||||
public String addModule(Module module) throws IOException;
|
||||
}
|
||||
|
||||
private static final String EXITING_LICENSE_NOT_ACKNOWLEDGED = "Exiting: license not acknowledged!";
|
||||
|
@ -181,7 +180,6 @@ public class BaseBuilder
|
|||
|
||||
if (!newly_added.isEmpty())
|
||||
{
|
||||
|
||||
if (Files.exists(startini) && Files.exists(startd))
|
||||
StartLog.warn("Use both %s and %s is deprecated",getBaseHome().toShortForm(startd),getBaseHome().toShortForm(startini));
|
||||
|
||||
|
@ -189,6 +187,7 @@ public class BaseBuilder
|
|||
builder.set(useStartD?new StartDirBuilder(this):new StartIniBuilder(this));
|
||||
newly_added.stream().map(n->modules.get(n)).forEach(module ->
|
||||
{
|
||||
String ini=null;
|
||||
try
|
||||
{
|
||||
if (module.isSkipFilesValidation())
|
||||
|
@ -197,8 +196,13 @@ public class BaseBuilder
|
|||
}
|
||||
else
|
||||
{
|
||||
if (builder.get().addModule(module))
|
||||
modified.set(true);
|
||||
// if (explictly added and ini file modified)
|
||||
if (startArgs.getStartModules().contains(module.getName()))
|
||||
{
|
||||
ini=builder.get().addModule(module);
|
||||
if (ini!=null)
|
||||
modified.set(true);
|
||||
}
|
||||
for (String file : module.getFiles())
|
||||
files.add(new FileArg(module,startArgs.getProperties().expand(file)));
|
||||
}
|
||||
|
@ -207,6 +211,26 @@ public class BaseBuilder
|
|||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
if (module.isDynamic())
|
||||
{
|
||||
for (String s:module.getEnableSources())
|
||||
StartLog.info("%-15s %s",module.getName(),s);
|
||||
}
|
||||
else if (module.isTransitive())
|
||||
{
|
||||
if (module.hasIniTemplate())
|
||||
StartLog.info("%-15s transitive, ini template available with --add-to-start=%s",
|
||||
module.getName(),
|
||||
module.getName());
|
||||
else
|
||||
StartLog.info("%-15s transitive",module.getName());
|
||||
}
|
||||
else
|
||||
StartLog.info("%-15s initialized in %s",
|
||||
module.getName(),
|
||||
ini);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -158,6 +158,8 @@ public class Modules implements Iterable<Module>
|
|||
index="";
|
||||
name="";
|
||||
}
|
||||
if (module.isTransitive() && module.hasIniTemplate())
|
||||
System.out.printf(" init template available with --add-to-start=%s%n",module.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,9 +314,6 @@ public class Modules implements Iterable<Module>
|
|||
m.expandProperties(_args.getProperties());
|
||||
}
|
||||
}
|
||||
else if (module.isTransitive() && module.hasIniTemplate())
|
||||
newlyEnabled.add(module.getName());
|
||||
|
||||
|
||||
// Process module dependencies (always processed as may be dynamic)
|
||||
for(String dependsOn:module.getDepends())
|
||||
|
@ -351,7 +350,7 @@ public class Modules implements Iterable<Module>
|
|||
// Is there an obvious default?
|
||||
Optional<Module> dftProvider = providers.stream().filter(m->m.getName().equals(dependsOn)).findFirst();
|
||||
if (dftProvider.isPresent())
|
||||
enable(newlyEnabled,dftProvider.get(),"default provider of "+dependsOn+" for "+module.getName(),true);
|
||||
enable(newlyEnabled,dftProvider.get(),"transitive provider of "+dependsOn+" for "+module.getName(),true);
|
||||
else if (StartLog.isDebugEnabled())
|
||||
StartLog.debug("Module %s requires %s from one of %s",module,dependsOn,providers);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class StartDirBuilder implements BaseBuilder.Config
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean addModule(Module module) throws IOException
|
||||
public String addModule(Module module) throws IOException
|
||||
{
|
||||
if (module.isDynamic())
|
||||
{
|
||||
|
@ -59,28 +59,20 @@ public class StartDirBuilder implements BaseBuilder.Config
|
|||
// warn
|
||||
StartLog.warn("%-15s not adding [ini-template] from dynamic module",module.getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
String mode = "";
|
||||
if (module.isTransitive())
|
||||
{
|
||||
mode = "(transitively) ";
|
||||
return null;
|
||||
}
|
||||
|
||||
if (module.hasIniTemplate() || !module.isTransitive())
|
||||
{
|
||||
// Create start.d/{name}.ini
|
||||
Path ini = startDir.resolve(module.getName() + ".ini");
|
||||
StartLog.info("%-15s initialised %sin %s",module.getName(),mode,baseHome.toShortForm(ini));
|
||||
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(ini,StandardCharsets.UTF_8,StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING))
|
||||
{
|
||||
module.writeIniSection(writer);
|
||||
}
|
||||
return true;
|
||||
return baseHome.toShortForm(ini);
|
||||
}
|
||||
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.start.builders;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
@ -86,13 +85,13 @@ public class StartIniBuilder implements BaseBuilder.Config
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean addModule(Module module) throws IOException
|
||||
public String addModule(Module module) throws IOException
|
||||
{
|
||||
if (modulesPresent.contains(module.getName()))
|
||||
{
|
||||
StartLog.info("%-15s already initialised in %s",module.getName(),baseHome.toShortForm(startIni));
|
||||
// skip, already present
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (module.isDynamic())
|
||||
|
@ -102,27 +101,19 @@ public class StartIniBuilder implements BaseBuilder.Config
|
|||
// warn
|
||||
StartLog.warn("%-15s not adding [ini-template] from dynamic module",module.getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
String mode = "";
|
||||
if (module.isTransitive())
|
||||
{
|
||||
mode = "(transitively) ";
|
||||
return null;
|
||||
}
|
||||
|
||||
if (module.hasIniTemplate() || !module.isTransitive())
|
||||
{
|
||||
StartLog.info("%-15s initialised %sin %s",module.getName(),mode,baseHome.toShortForm(startIni));
|
||||
|
||||
// Append to start.ini
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(startIni,StandardCharsets.UTF_8,StandardOpenOption.APPEND,StandardOpenOption.CREATE))
|
||||
{
|
||||
module.writeIniSection(writer);
|
||||
}
|
||||
return true;
|
||||
return baseHome.toShortForm(startIni);
|
||||
}
|
||||
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ LIB|${jetty.home}/lib/extra/extra1.jar
|
|||
|
||||
# The Properties we expect (order is irrelevant)
|
||||
PROP|extra.prop=value0
|
||||
PROP|main.prop=valueT
|
||||
PROP|main.prop=value0
|
||||
PROP|optional.prop=value0
|
||||
|
||||
# Files / Directories to create
|
||||
|
|
|
@ -14,12 +14,11 @@ LIB|${jetty.home}/lib/extra/extra1.jar
|
|||
|
||||
# The Properties we expect (order is irrelevant)
|
||||
PROP|extra.prop=value0
|
||||
PROP|main.prop=valueT
|
||||
PROP|main.prop=value0
|
||||
PROP|optional.prop=value0
|
||||
|
||||
# Files / Directories to create
|
||||
EXISTS|maindir/
|
||||
EXISTS|start.d/main.ini
|
||||
EXISTS|start.d/extra.ini
|
||||
EXISTS|start.d/optional.ini
|
||||
|
||||
|
|
|
@ -14,12 +14,11 @@ LIB|${jetty.home}/lib/extra/extra1.jar
|
|||
|
||||
# The Properties we expect (order is irrelevant)
|
||||
PROP|extra.prop=value0
|
||||
PROP|main.prop=valueT
|
||||
PROP|main.prop=value0
|
||||
PROP|optional.prop=value0
|
||||
|
||||
# Files / Directories to create
|
||||
EXISTS|maindir/
|
||||
EXISTS|start.d/
|
||||
EXISTS|start.d/main.ini
|
||||
EXISTS|start.d/extra.ini
|
||||
EXISTS|start.d/optional.ini
|
||||
|
|
|
@ -4,5 +4,8 @@ etc/t.xml
|
|||
[optional]
|
||||
main
|
||||
|
||||
[ini]
|
||||
transient.option=transient
|
||||
|
||||
[ini-template]
|
||||
transient.option=transient
|
||||
|
|
Loading…
Reference in New Issue