jlgrock / ClosureJavascriptFramework

A group of plug-ins that can be used in conjunction with maven to execute the Google Closure Compiler on JavaScript code. This Framework allows for scaling and modularity.
MIT License
16 stars 7 forks source link

Issue configuring via pom #25

Closed pgilmore closed 11 years ago

pgilmore commented 11 years ago

Hi,

In the latest version we have an issue configuring via pom.xml.

This is the target in pom.xml

                    <plugin>
                            <groupId>org.mojo.javascript-framework</groupId>
                            <artifactId>closure-compiler-maven-plugin</artifactId>
                            <version>${jsframework.version}</version>
                            <configuration>
                                    <compileLevel>SIMPLE_OPTIMIZATIONS</compileLevel>
                                    <errorlevel>SIMPLE</errorlevel>
                            </configuration>
                    </plugin>

However the configuration is never read. Temporarely we've set them using project properties instead however this requires us to use our own repository. Would much rather be able to use the public version.

Is this something you've experienced also? Or is there something in our configuration that is screwed?

I've debugged the plugin and the config variables aren't read from the pom. We've got quite a few other plugins that are similar but they have no issue reading the config section.

Keep up the great work!

Cheers Patrick

pgilmore commented 11 years ago

If this is a known issue I can try and fix it but wanted to know if there is something I'm missing first.

jlgrock commented 11 years ago

Sorry for the slow response, this is definitely something that should be working. I've been tied up with possibly changing jobs, so that killed my performance on this project. I'll check it out and get it working today/tomorrow.

jlgrock commented 11 years ago

OK, with this configuration, I have no problem applying the WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS, and ADVANCED_OPTIMIZATIONS. Attempting the "errorlevel" tag

jlgrock commented 11 years ago

k, found out there are problems with "errorlevel". First off, it's case sensitive, so change the tags to "errorLevel". Also, it seems that it's either on or off. I'm trying to add better levels right now.

jlgrock commented 11 years ago

OK, I have pushed some code to aleviate this problem. It's doing a much better job of printing warnings and adjusting to different warning levels. Also, I've added a new "NONE" option to the errorLevel, which means that, as long as the code can compile, it will. This is obviously not suggested, and I'm going to leave the strict default the same, but this will allow you to degrade a little more gracefully in the face of issues. If you are running into anything with problems with the compiler output, let me know too and I might be able to help troubleshoot.

Anyways, give the code I just pushed a try, and assuming it works for the both of us, I'll create a new version and push it out to maven central.

pgilmore commented 11 years ago

I'll test it out and get back to you.

Cheers Patrick

jlgrock commented 11 years ago

As a heads up, I released a 1.15.0. This should include what you were looking for. Hope this is easier to test with. This includes the new version of the compiler though, so there are additional checks that the Closure team has introduced. Keep that in mind if upgrading.

pgilmore commented 11 years ago

Thanks man!

We're rapidly nearing us release so haven't had time to test it yet :( Will try it out this weekend.

Cheers Patrick

On Wed, Dec 19, 2012 at 3:35 AM, Justin Grant notifications@github.comwrote:

As a heads up, I released a 1.15.0. This should include what you were looking for. Hope this is easier to test with. This includes the new version of the compiler though, so there are additional checks that the Closure team has introduced. Keep that in mind if upgrading.

— Reply to this email directly or view it on GitHubhttps://github.com/jlgrock/ClosureJavascriptFramework/issues/25#issuecomment-11515199.

Phone: +46709927315 GTalk: patrick.gilmore@noonday.se

http://no.linkedin.com/in/patrickgilmore

pgilmore commented 11 years ago

Tried it out now.

We must have something really wrong in our pom.xml. It does not read the configuration part at all. Can you spot anything wrong here that would disable configuration for the closure plugin?

Thanks!

This is the plugin part:

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.0.1</version>
            <executions>
                <execution>
                    <id>prepare-war</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>exploded</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <inherited>true</inherited>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <optimize>true</optimize>
                <debug>true</debug>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>${jetty.version}</version>
            <configuration>
                <connectors>
                    <connector implementation="org.eclipse.jetty.server.bio.SocketConnector">
                        <port>8080</port>
                        <maxIdleTime>3600000</maxIdleTime>
                    </connector>
                </connectors>
                <contextPath>/</contextPath>
                <webXml>src/main/webapp/WEB-INF/web-development.xml</webXml>
                <contextHandlers>
                    <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                        <war>target/xxx-web-1.0-SNAPSHOT/javascript/generated/closure-library</war>
                        <contextPath>/javascript/generated/closure-library</contextPath>
                    </contextHandler>
                    <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                        <war>target/xxx-web-1.0-SNAPSHOT/javascript/generated/output</war>
                        <contextPath>/javascript/generated/output</contextPath>
                    </contextHandler>
                    <contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
                        <war>src/main/javascript</war>
                        <contextPath>/javascript/generated/output/assertionSource</contextPath>
                    </contextHandler>
                </contextHandlers>
            </configuration>
        </plugin>

        <plugin>
            <groupId>com.github.jlgrock.javascript-framework</groupId>
            <artifactId>jsar-maven-plugin</artifactId>
            <version>${jsframework.version}</version>
            <extensions>true</extensions>
        </plugin>

        <plugin>
            <groupId>org.mojo.javascript-framework</groupId>
            <artifactId>closure-compiler-maven-plugin</artifactId>
            <version>${jsframework.version}</version>
            <configuration>
                <compileLevel>SIMPLE_OPTIMIZATIONS</compileLevel>
                <errorLevel>SIMPLE</errorLevel>
            </configuration>
        </plugin>

        <!-- publishes aggregate source code into an archive -->
        <plugin>
            <groupId>com.github.jlgrock.javascript-framework</groupId>
            <artifactId>source-archive-maven-plugin</artifactId>
            <version>${jsframework.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>js-gen-source-archive</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>com.xxx.suite.server</groupId>
            <artifactId>xxx-maven-template-merger</artifactId>
            <version>1.0-SNAPSHOT</version>
            <configuration>
                <merges>
                    <merge>
                        <targetFile>${project.build.directory}/${project.artifactId}-${project.version}/javascript/generated/output/compiled/tpl.js</targetFile>
                        <sourceDir>src/main/webapp/tpl</sourceDir>
                    </merge>
                </merges>
            </configuration>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>merge</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>com.google.code.maven-replacer-plugin</groupId>
            <artifactId>maven-replacer-plugin</artifactId>
            <executions>
                <execution>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>replace</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <encoding>UTF-8</encoding>
                <filesToInclude>target/${project.build.finalName}/**/**.html,target/${project.build.finalName}/**/**.js,,target/${project.build.finalName}/**/**.css</filesToInclude>
                <replacements>
                    <replacement>
                        <token>(javascript|lib|i18n)/(.*)\.js</token>
                        <value>$1/$2.js?v=${maven.build.timestamp}</value>
                    </replacement>
                    <replacement>
                        <token>['"].js["']([;,])</token>
                        <value>'.js?v=${maven.build.timestamp}'$1</value>
                    </replacement>
                    <replacement>
                        <token>css/(.*)\.css</token>
                        <value>css/$1.css?v=${maven.build.timestamp}</value>
                    </replacement>
                    <replacement>
                        <token>img/(.*)\.png</token>
                        <value>img/$1.png?v=${maven.build.timestamp}</value>
                    </replacement>
                    <replacement>
                        <token>img/(.*)\.gif</token>
                        <value>img/$1.gif?v=${maven.build.timestamp}</value>
                    </replacement>
                    <replacement>
                        <token>img/(.*)\.jpg</token>
                        <value>img/$1.jpg?v=${maven.build.timestamp}</value>
                    </replacement>
                </replacements>
            </configuration>
        </plugin>
    </plugins>
jlgrock commented 11 years ago

Just realized what is going on. I checked your configuration, but didn't notice that the "groupId" is wrong. I'm actually kinda amazed that maven didn't blow up on this. Change the "groupId" to "com.github.jlgrock.javascript-framework". I had to look for it, but this was absolutely a mistake in the wiki pages that I had thrown together from when I initially put together the plugin. I went through an corrected those references. Sorry for any confusion that has caused.

Also, as a note, if you should desire it, you can split your javascript from your war project for reuse with my plugin. We do this with our code, making a js library which can get pulled into multiple war projects using the war packaging. You can take a look at https://github.com/jlgrock/ClosureFrameworkLibraryExample for an example of this, if you so desire.

On the other hand, I'm glad you did paste your pom, as I've never used the google maven-replacer-plugin. It looks better than the replacer I'm using. I may have to start looking at a replacement...

Hopefully that will fix your problem. And if you run into an issue like that again, don't hesitate to send me a message.

pgilmore commented 11 years ago

How embarrassing :)

Problem solved and thanks for you tip to split js from war!

Cheers

jlgrock commented 11 years ago

No Worries. I aim to help :)