package com.mycode;

import java.util.Optional;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.WebInfConfiguration;

public class App {

    public static void main(String[] args) throws Exception {

        String portString = Optional.ofNullable(System.getenv("PORT"))
                .orElse("8080");
        int port = Integer.parseInt(portString);
        Server server = new Server(port);

        WebAppContext ctx = new WebAppContext();
        ctx.setResourceBase("src/main/webapp/public");
//        ctx.setContextPath("/shop");
        ServletHandler handler = new ServletHandler();
        handler.addServletWithMapping(FruitsServlet.class, "/fruitsServlet");
        ctx.setServletHandler(handler);

        /* おまじない ここから */
        ctx.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*jstl.*\\.jar$");
        // http://localhost:8080/webjars/jquery/2.2.3/jquery.min.js
        // http://www.programcreek.com/java-api-examples/index.php?api=org.eclipse.jetty.webapp.WebInfConfiguration
        // Example 17
        ctx.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, ".*/org\\.eclipse\\.xtext\\.web.*,.*/org.webjars.*");
        ctx.setClassLoader(App.class.getClassLoader());
        org.eclipse.jetty.webapp.Configuration.ClassList classlist = org.eclipse.jetty.webapp.Configuration.ClassList.setServerDefault(server);
        classlist.addAfter("org.eclipse.jetty.webapp.FragmentConfiguration", "org.eclipse.jetty.plus.webapp.EnvConfiguration", "org.eclipse.jetty.plus.webapp.PlusConfiguration");
        classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");
        /* おまじない ここまで */

        server.setHandler(ctx);
        server.start();
        server.join();
    }
}

@@ -159,28 +159,40 @@
 tty.
-webapp.WebAppContext
+util.resource.ResourceCollection
 ;%0Aim
@@ -224,32 +224,26 @@
 bapp.Web
-InfConfiguration
+AppContext
 ;%0A%0Apubli
@@ -577,52 +577,257 @@
     
-ctx.setResourceBase(%22src/main/webapp/public%22
+ResourceCollection resources = new ResourceCollection(new String%5B%5D%7B%0A            %22src/main/webapp/public%22,%0A            App.class.getClassLoader().getResource(%22META-INF/resources/%22).toURI().toString()%0A        %7D);%0A%0A        ctx.setBaseResource(resources
 );%0A/
@@ -1180,392 +1180,8 @@
 %22);%0A
-        // http://localhost:8080/webjars/jquery/2.2.3/jquery.min.js%0A        // http://www.programcreek.com/java-api-examples/index.php?api=org.eclipse.jetty.webapp.WebInfConfiguration%0A        // Example 17%0A        ctx.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, %22.*/org%5C%5C.eclipse%5C%5C.xtext%5C%5C.web.*,.*/org.webjars.*%22);%0A        ctx.setClassLoader(App.class.getClassLoader());%0A
     

modify Procfile