Jasig / jspc-maven-plugin

UNMAINTAINED Maven plugin that compiles JSPs
http://unmaintained.tech/
Apache License 2.0
24 stars 38 forks source link

Do not stop on first JSP containing a compile error #17

Open Lynorics opened 10 years ago

Lynorics commented 10 years ago

It would be really helpful, if the compiler would not stop on the first JSP with compile errors, but continue until the last has been compiled---within the same maven module, of course.

If some users prefer the old way (stop on first compile error), an option like "jspc.failFast" should be introduced.

Additionally, a line showing some statistics would be really nice, like total: 127 (JSP files) errors: 42 (JSP files)

Also see https://issues.apache.org/bugzilla/show_bug.cgi?id=53011

Lynorics commented 10 years ago

Here is the code snippet which replaces the while-loop in class JspC. In order to use the patch without patching the Jasper-Compiler you have to clone the class JspC into your project jspc-compiler-tomcatN.

            long time=System.currentTimeMillis();
            int errors = 0;
            while (iter.hasNext()) {
                String nextjsp = iter.next().toString();
                File fjsp = new File(nextjsp);
                if (!fjsp.isAbsolute()) {
                    fjsp = new File(uriRootF, nextjsp);
                }
                if (!fjsp.exists()) {
                    if (log.isWarnEnabled()) {
                        log.warn
                            (Localizer.getMessage
                             ("jspc.error.fileDoesNotExist", fjsp.toString()));
                    }
                    continue;
                }
                String s = fjsp.getAbsolutePath();
                if (s.startsWith(uriRoot)) {
                    nextjsp = s.substring(uriRoot.length());
                }
                if (nextjsp.startsWith("." + File.separatorChar)) {
                    nextjsp = nextjsp.substring(2);
                }
                try {
                    processFile(nextjsp);
                }
                catch(JasperException ex) {
                    errors++;
                    log.error(nextjsp + ":" + ex.getMessage());
                }
            }
            String timeFromatted = new DecimalFormat("#.###").format((double)(System.currentTimeMillis()-time)/1000);
            System.out.println("JSP-compilations: "+pages.size()+", Errors: "+errors+", Time elapsed: "+timeFromatted+" sec");
            if (errors > 0) {
                throw new JasperException("Aborted due to compilation failures!");
            }

Edit: Added syntax highlighting to java snippet

ChristianMurphy commented 7 years ago

@akram @Lynorics would either of you be interested in updating #19 so this feature could be merged in?

ChristianMurphy commented 7 years ago

Hey there! :wave:

Thanks for opening an issue with jspc-maven-plugin. :+1: :bowing_man: At the moment, the jspc maven plugin does not have an active maintainer to process your request. :no_entry: While the Jasig jspc maven plugin is without an active maintainer, we recommend the Apache Sling jspc maven plugin and the Jetty jspc maven plugin as alternatives that are actively maintained. :white_check_mark: If you are interested in becoming a project maintainer, there is a uPortal-dev list post where you can register your interest. :email:

Thanks again for contributing to the jspc-maven-plugin! :sparkles: