Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/main/assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
<include>jbake-core.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>plugin</outputDirectory>
<excludes>
<exclude>**/*</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${basedir}</directory>
<outputDirectory></outputDirectory>
Expand Down
52 changes: 20 additions & 32 deletions src/main/java/org/jbake/launcher/Main.java
Original file line number Diff line number Diff line change
@@ -1,58 +1,46 @@
package org.jbake.launcher;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import java.util.Iterator;
import java.util.ServiceLoader;

import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.ConfigurationUtils;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.server.nio.NetworkTrafficSelectChannelConnector;
import org.jbake.app.ConfigUtil;
import org.jbake.app.FileUtil;
import org.jbake.app.Oven;
import org.jbake.app.ZipUtil;
import org.jbake.plugins.JBakePlugin;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;

/**
* Launcher for JBake.
*
*
* @author Jonathan Bullock <jonbullock@gmail.com>
*
*/
public class Main {
// public static final String VERSION = "v2.2";

private final String USAGE_PREFIX = "Usage: jbake";

/**
* Runs the app with the given arguments.
*
*
* @param String[] args
*/
public static void main(String[] args) {
Iterator<JBakePlugin> plugins = ServiceLoader.load(JBakePlugin.class).iterator();
while (plugins.hasNext()) {
JBakePlugin plugin = plugins.next();
plugin.init();
}

Main m = new Main();
m.run(m.parseArguments(args));
}

private void run(LaunchOptions options) {
try {
Oven oven = new Oven(options.getSource(), options.getDestination());
Expand All @@ -78,14 +66,14 @@ private LaunchOptions parseArguments(String[] args) {
e.printStackTrace();
System.exit(1);
}

System.out.println("JBake " + config.getString("version") + " (" + config.getString("build.timestamp") + ") [http://jbake.org]");
System.out.println();

if (res.isHelpNeeded()) {
printUsage(parser);
}

if (res.isRunServer()) {
if (res.getSource().getPath().equals(".")) {
// use the default destination folder
Expand All @@ -94,7 +82,7 @@ private LaunchOptions parseArguments(String[] args) {
runServer(res.getSource().getPath(), config.getString("server.port"));
}
}

if (res.isInit()) {
initStructure(config);
}
Expand All @@ -119,7 +107,7 @@ private void runServer(String path, String port) {
JettyServer.run(path, port);
System.exit(0);
}

private void initStructure(CompositeConfiguration config) {
Init init = new Init(config);
try {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/jbake/plugins/JBakePlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.jbake.plugins;

public interface JBakePlugin {

void init();
}
2 changes: 1 addition & 1 deletion src/main/scripts/jbake
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
JBAKE_HOME="`dirname "$0"`"
java -jar ${JBAKE_HOME}/jbake-core.jar $@
java -cp "${JBAKE_HOME}/jbake-core.jar:plugin/*" org.jbake.launcher.Main $@