Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

Adding support for ClosureBuilder and DepsWriter python tools #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jamiefolson
Copy link

Should be pretty self-explanatory. This improves support for Google Closure by incorporating the closurebuild.py and depswriter.py scripts into gradle tasks.

Details:
Builder:
In addition to simply combining the required files in order, you can also use the build task to compile the javascript code(task.compile = true, which is the default). Rather that passing the compiler jar file to closurebuilder, this dynamically creates a minifyJs task in order to reuse compiler options specified in the closure extension.

Library:
A 'getClosure' task is added which can retrieve the closure library (which contains the python scripts). The location for where to download the library is 'project.closure.library.location'. If that location exists, the getClosure task is skipped.

Extensions:
I changed the ClosureCompilerExtension to a ClosureExtension, which is completely backwards compatible in the DSL, but seperates the library and compiler configuration while containing them all inside the ClosureExtension.

Example:
I was not entirely clear on how the tests were organized, so I simply created a notepad.gradle config file for the added notepad.js file. If everything looks reasonable, I can commit changes to the Readme.md, too, but I wanted to get some feedback on things, first.

The following tasks are added to the project:
getClosure : Uses git to download a copy of the closure library to the
specified location.  If the location exists, this task is skipped

buildJs : Uses the Closure Builder python script to order and combine
all dependencies for the specified namespace

depsJs : Use depswriter.py to write out the locations of the project
files for use with goog.require

The Closure tutorial's notepad.js is added as an example with
notepad.gradle showing how to configure it
@eriwen
Copy link
Owner

eriwen commented Feb 22, 2013

Thanks for the code! I'm hoping address your issues and this PR this weekend. Cheers.

@eriwen eriwen closed this Feb 22, 2013
@eriwen eriwen reopened this Feb 22, 2013
@eriwen
Copy link
Owner

eriwen commented Feb 25, 2013

I really like the idea of closurebuilder support - thanks again. I would prefer that we not introduce a dependency on another Gradle plugin and pull from Google Code. Instead, I think we should simply put the python scripts in src/main/resources and utilize them from there, even though that locks the version. An even better solution would be to pull the Closure Library scripts from a JAR hosted on a common repository (like Maven Central). Maybe someone has already done this?

Would you be willing to address this @jamiefolson? I'd be great if you could perhaps add a functional test to JsPluginFunctionalTest or perhaps some documentation for the README.

Thanks again for your suggestions and contributions. Cheers.

@jamiefolson
Copy link
Author

I feel your concerns. I think that'd be a good solution for the python scripts, but I'm not really sure how up-to-date the library on Maven Central is. It still points to the old subversion location, but I haven't looked into it to see if it's really that old or if they just haven't updated the url.

Would it be bad to just throw an error if the library directory doesn't exist and tell people to download a copy?

I wasn't sure about trying to "version" the closure library, since even Google just says to clone the repo. They don't even seem to host any versioned snapshots.

Edit: FYI: Either way, I'll add some more documentation. I'll try to add a test to JsPluginFunctionalTest, but I'm not entirely familiar with spock, so we'll see how it goes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants