Search code examples
eclipsetapestry

New TML files don't compile automatically in eclipse?


I am working my way through the Tapestry 5 tutorial and I have notices that changes to the TML files (or new TML files for that matter) don't automatically compile from inside eclipse. I can only get the new TML files or changes to any TML file to be realized by going out to the command line and "mvn package". That can't be right.

In eclipse this is a Maven project and I executed the whole "mvn eclipse:eclipse -DdownloadSources=true" thing, so its hard to believe that the eclipse project is not configured correctly.

It is as if *tml files do not qualify for automatic copy into the targets directory like compiled *java files would or *properties file.

What do I have to do to get this project configured for more interactive debugging?


Solution

  • Personally, I always add a test dependency to Jetty and launch it with the following class. Because the code is run from eclipse's classpath, whatever eclipse sees, the jetty web app also sees. Therefore you never have any problems with resource dirs.

    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty</artifactId>
        <version>6.1.26</version>
    </dependency>
    
    package jetty;
    import org.apache.tapestry5.SymbolConstants;
    import org.mortbay.jetty.Connector;
    import org.mortbay.jetty.Server;
    import org.mortbay.jetty.handler.ContextHandlerCollection;
    import org.mortbay.jetty.nio.SelectChannelConnector;
    import org.mortbay.jetty.webapp.WebAppContext;
    
    /**
     * For jetty 6
     * @see http://docs.codehaus.org/display/JETTY/Embedding+Jetty#comment-4391085
     */
    public class JettyWebServer {
        public static String     context = "/";
        public static int         port     = 8069;
    
        private Server jettyServer;
    
        public void start() throws Exception {
            System.setProperty(SymbolConstants.PRODUCTION_MODE, "false");
    
            jettyServer = new Server();
            Connector connector = new SelectChannelConnector();
            connector.setPort(port);
            connector.setHost("127.0.0.1");
            jettyServer.addConnector(connector);
    
            WebAppContext context = new WebAppContext("src/web/", JettyWebServer.context);
            context.setLogUrlOnStart(true);
            context.setParentLoaderPriority(true);
            jettyServer.setStopAtShutdown(true);
    
            ContextHandlerCollection contexts = new ContextHandlerCollection();
            contexts.addHandler(context);
            jettyServer.setHandler(contexts);
    
            jettyServer.start();
        }
    
        public void join() throws Exception {
            jettyServer.join();
        }
    
        public void stop() throws Exception {
            if (jettyServer != null)
                jettyServer.stop();
        }
    
        public static void main(String[] args) throws Exception {
            JettyWebServer server = new JettyWebServer();
            try {
                server.start();
                server.join();
            } finally {
                server.stop();
            }
        }
    }