pax_global_header00006660000000000000000000000064123767534100014522gustar00rootroot0000000000000052 comment=a385ad851fc6cdaee298e3b013d31fb14b0c94ad minify-maven-plugin-minify-maven-plugin-1.7.4/000077500000000000000000000000001237675341000213175ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/.gitignore000066400000000000000000000000451237675341000233060ustar00rootroot00000000000000target .settings .project .classpath minify-maven-plugin-minify-maven-plugin-1.7.4/CHANGELOG.md000066400000000000000000000135271237675341000231400ustar00rootroot00000000000000# Minify Maven Plugin ## 1.7.4 * Update Google Closure Compiler to v20140814 (#71). * Add support for Closure Library dependencies sorting (#70). * Add option to use default externs provided with the Google Closure Compiler (#67). ## 1.7.3 * Improve docs: missing information about file order (#45). * Select the JVM default charset as the value for the `charset` option when none is defined (#48). * Add a warning message to `nosuffix` option Javadoc (#50). * Add support for JavaScript Source Maps (#41). * Update Google Closure Compiler to v20140625. * Add support for Google Closure Compiler `angular_pass` option (#60). * Rename `yuiLinebreak` option to `yuiLineBreak`. * Rename `yuiMunge` option to `yuiNoMunge`. * Rename `yuiPreserveAllSemiColons` option to `yuiPreserveSemicolons`. * Fail build when a specified source file is not found (#53). ## 1.7.2 * Update default `charset` value to `${project.build.sourceEncoding}`. * Deprecate the option `debug`. `verbose` should be used instead. * Change YUI option's names to clearly indicate that they are specific to YUI Compressor. * Update Google Closure Compiler to v20130823. * Add support for Google Closure Compiler `language` option (#24). * Add support for Google Closure Compiler `compilation_level` option. * Add support for Google Closure Compiler `externs` option (#22). * Fail build with Google Closure Compiler on parse errors. ## 1.7.1 * Update Google Closure Compiler to v20130722. * Preserve sub-directory structure when only minifying (#29). * Delete transient `.tmp` file on spot in case of `nosuffix = true` (#32). * Use annotations to generate the plugin descriptor file. ## 1.7 * Added `nosuffix` option to avoid the suffix `.min` on the minified output file name (#16). * Option to use same subdirectory on target as in source (#17). * Build should fail if compiler can't parse/compile source files (#19). * Add `UTF-8` as the default charset. * Log compression gains. * Require Java SE 7 for better resource management. See [AutoCloseable](http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html) interface and [try-with-resources](http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html) statements. ## 1.6 * Add support for [Google Closure Compiler](https://developers.google.com/closure/compiler/) for JavaScript compression (#14). ## 1.5.2 * New goal parameter to log full source file paths and new FAQ entry pointing to the plugin goal parameters (#5). * Option to skip the minify step (#11). * Option to skip the merge step (#13). ## 1.5.1 * Cannot process the same file name of files in different directories (#2). * CSS minification fails for base64 encoded background images (#3). ## 1.5 * Fix charset issue (#1). * Update Maven site skin. * Use `ExecutorService` to wait for all tasks to finish. * Add support for CLI-based configuration and Maven 2.2.1. From [Configuring Plugin Goals in Maven 3](http://www.sonatype.com/people/2011/03/configuring-plugin-goals-in-maven-3/): > For many plugin parameters it is occasionally convenient to specify their values from the command line via system properties. In the past, this was limited to parameters of simple types like `String` or `Boolean`. The latest Maven release finally allows plugin users to configure collections or arrays from the command line via comma-separated strings. Take for example a plugin parameter like this: > > /** @parameter expression="${includes}" */ > String[] includes; > > This can be configured from the command line as follows: > > mvn -Dincludes=Foo,Bar > > Plugin authors that wish to enable CLI-based configuration of arrays/collections just need to add the `expression` tag to their parameter annotation. Note that if compatibility with older Maven versions is to be kept, the parameter type must not be an interface but a concrete collection class or an array to avoid another shortcoming in the old configurator. ## 1.4 * Move from http://code.google.com/p/maven-samaxes-plugin/ to https://github.com/samaxes/minify-maven-plugin. * Add Maven Integration for Eclipse (M2E) lifecycle mapping metadata. * Rename project from Maven Minify Plugin to Minify Maven Plugin: > Artifact Ids of the format maven-___-plugin are reserved for > plugins in the Group Id org.apache.maven.plugins > Please change your artifactId to the format ___-maven-plugin > In the future this error will break the build. ## 1.3.5 * Lift restriction that prevented the final file name to be the same as an existing source file name. ## 1.3.4 * Update YUI Compressor to version 2.4.6. ## 1.3.3 * Add debug messages for wrong source file names and source directory paths. ## 1.3.2 * Add `cssTargetDir`, `jsTargetDir`, `suffix`, and `charset` parameters. ## 1.3.1 * Class `java.util.List` cannot be instantiated while running Maven minify goal with versions previous to 3.0. ## 1.3 * Change exclude/include patterns from a comma separated `String` to `List`. Also included a custom file comparator that only compares the file name instead of the full file path. * Update [YUI Compressor](http://yui.github.com/yuicompressor/) dependency to version 2.4.2. ## 1.2.1 * Don't crash with an `IndexOutOfBoundsException` when a source file does not exist. * More accurate logging. * Configure POM to inherit from Sonatype OSS Parent POM. ## 1.2 * Add exclude/include patterns, with the caveat that the developer must name their source files so their lexicographical order is correct for minifying. * Don't minify a file type if the list of files to process is empty. * Make JavaScript minify error messages clearer. * Make file extensions configurable (e.g. it's now possible to save a JavaScript file as `*.jsp` or `*.php`). * Compile against JDK 1.5 instead of JDK 1.6. minify-maven-plugin-minify-maven-plugin-1.7.4/LICENSE.txt000066400000000000000000000261361237675341000231520ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. minify-maven-plugin-minify-maven-plugin-1.7.4/README.md000066400000000000000000000061431237675341000226020ustar00rootroot00000000000000# Minify Maven Plugin Minify Maven Plugin combines and minimizes your CSS and JavaScript files for faster page loading. It produces a merged and a minified version of your CSS and JavaScript resources which can be re-used across your project. Under the hood, it uses the [YUI Compressor](http://yui.github.com/yuicompressor/) and [Google Closure Compiler](https://developers.google.com/closure/compiler/) but has a layer of abstraction around these tools which allows for other tools to be added in the future. ## Benefits ### Reduce HTTP Requests > 80% of the end-user response time is spent on the front-end. Most of this time is tied up in downloading all the components in the page: images, stylesheets, scripts, etc. Reducing the number of components in turn reduces the number of HTTP requests required to render the page. This is the key to faster pages. > Combined files are a way to reduce the number of HTTP requests by combining all scripts into a single script, and similarly combining all CSS into a single stylesheet. Combining files is more challenging when the scripts and stylesheets vary from page to page, but making this part of your release process improves response times. ### Compress JavaScript and CSS > Minification/compression is the practice of removing unnecessary characters from code to reduce its size thereby improving load times. A JavaScript compressor, in addition to removing comments and white-spaces, obfuscates local variables using the smallest possible variable name. This improves response time performance because the size of the downloaded file is reduced. ## Usage Configure your project's `pom.xml` to run the plugin during the project's build cycle. ```xml com.samaxes.maven minify-maven-plugin 1.7.4 default-minify UTF-8 file-1.css file-n.css file-1.js file-n.js CLOSURE minify ``` For more information, check the [plugin documentation](http://samaxes.github.com/minify-maven-plugin/) or the [demo application](https://github.com/samaxes/minify-maven-plugin/releases/download/minify-maven-plugin-1.7.4/minify-maven-plugin-demo-1.7.4-src.zip). ## System Requirements Since the version 1.7, Minify Maven Plugin requires Java 7 to run. If you need to support older versions of Java please use the version 1.6 or bellow. ## License This distribution is licensed under the terms of the Apache License, Version 2.0 (see LICENSE.txt). minify-maven-plugin-minify-maven-plugin-1.7.4/demo/000077500000000000000000000000001237675341000222435ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/demo/pom.xml000066400000000000000000000067221237675341000235670ustar00rootroot00000000000000 4.0.0 com.samaxes.maven minify-maven-plugin-demo 1.7.4 war Minify Maven Plugin Demo How to use the maven plugin minify-maven-plugin. https://github.com/samaxes/minify-maven-plugin org.apache.maven.plugins maven-assembly-plugin 2.4 src org.apache.maven.plugins maven-war-plugin 2.4 **/reset.css,**/fonts.css,**/base.css,**/toc.css,**/samaxesjs.core.js,**/samaxesjs.toc.js com.samaxes.maven minify-maven-plugin 1.7.4 default-minify reset.css fonts.css base.css toc.css samaxesjs.core.js subdir/samaxesjs.toc.js CLOSURE true minify UTF-8 1.5 1.5 true minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/000077500000000000000000000000001237675341000230325ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/000077500000000000000000000000001237675341000237565ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/000077500000000000000000000000001237675341000252345ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/WEB-INF/000077500000000000000000000000001237675341000262635ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/WEB-INF/web.xml000066400000000000000000000006531237675341000275660ustar00rootroot00000000000000 Minify Maven Plugin Example minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/css/000077500000000000000000000000001237675341000260245ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/css/base.css000066400000000000000000000043461237675341000274570ustar00rootroot00000000000000/* Copyright (c) 2009, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 2.7.0 */ /** * YUI Base * @module base * @namespace yui- * @requires reset, fonts */ body { /* For breathing room between content and viewport. */ margin:10px; } h1 { /* 18px via YUI Fonts CSS foundation. */ font-size: 138.5%; } h2 { /* 16px via YUI Fonts CSS foundation. */ font-size: 123.1%; } h3 { /* 14px via YUI Fonts CSS foundation. */ font-size: 108%; } h1,h2,h3 { /* Top & bottom margin based on font size. */ margin: 1em 0; } h1,h2,h3,h4,h5,h6,strong,dt { /* Bringing boldness back to headers and the strong element. */ font-weight: bold; } optgroup { font-weight:normal; } abbr,acronym { /* Indicating to users that more info is available. */ border-bottom: 1px dotted #000; cursor: help; } em { /* Bringing italics back to the em element. */ font-style: italic; } del { /* Striking deleted phrases. */ text-decoration: line-through; } blockquote,ul,ol,dl { /* Giving blockquotes and lists room to breath. */ margin: 1em; } ol,ul,dl { /* Bringing lists on to the page with breathing room. */ margin-left: 2em; } ol li { /* Giving OL's LIs generated numbers. */ list-style: decimal outside; } ul li { /* Giving UL's LIs generated disc markers. */ list-style: disc outside; } dl dd { /* Giving UL's LIs generated numbers. */ margin-left: 1em; } th,td { /* Borders and padding to make the table readable. */ border: 1px solid #000; padding: .5em; } th { /* Distinguishing table headers from data cells. */ font-weight: bold; text-align: center; } caption { /* Coordinated margin to match cell's padding. */ margin-bottom: .5em; /* Centered so it doesn't blend in to other content. */ text-align: center; } sup { /* to preserve line-height and selector appearance */ vertical-align: super; } sub { /* to preserve line-height and selector appearance */ vertical-align: sub; } p, fieldset, table, pre { /* So things don't run into each other. */ margin-bottom: 1em; } /* Opera requires 1px of passing to render with contemporary native chrome */ button, input[type="checkbox"], input[type="radio"], input[type="reset"], input[type="submit"] { padding:1px; } minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/css/fonts.css000066400000000000000000000016241237675341000276720ustar00rootroot00000000000000/* Copyright (c) 2009, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 2.7.0 */ /** * YUI Fonts * @module fonts * @namespace yui- * @requires */ /** * Percents could work for IE, but for backCompat purposes, we are using keywords. * x-small is for IE6/7 quirks mode. */ body { font:13px/1.231 arial,helvetica,clean,sans-serif; /* for IE6/7 */ *font-size:small; /* for IE Quirks Mode */ *font:x-small; } /** * Nudge down to get to 13px equivalent for these form elements */ select, input, button, textarea, button { font:99% arial,helvetica,clean,sans-serif; } /** * To help tables remember to inherit */ table { font-size:inherit; font:100%; } /** * Bump up IE to get to 13px equivalent for these fixed-width elements */ pre, code, kbd, samp, tt { font-family:monospace; *font-size:108%; line-height:100%; } minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/css/reset.css000066400000000000000000000024431237675341000276630ustar00rootroot00000000000000/* Copyright (c) 2009, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 2.7.0 */ /** * YUI Reset * @module reset * @namespace * @requires */ html { color: #000; background: #FFF; } body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td { margin: 0; padding: 0; } table { border-collapse: collapse; border-spacing: 0; } fieldset, img { border: 0; } address, caption, cite, code, dfn, em, strong, th, var, optgroup { font-style: inherit; font-weight: inherit; } del, ins { text-decoration: none; } li { list-style: none; } caption, th { text-align: left; } h1, h2, h3, h4, h5, h6 { font-size: 100%; font-weight: normal; } q:before, q:after { content: ''; } abbr, acronym { border: 0; font-variant: normal; } sup { vertical-align: baseline; } sub { vertical-align: baseline; } /*because legend doesn't inherit in IE */ legend { color: #000; } input, button, textarea, select, optgroup, option { font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; } /*@purpose To enable resizing for IE */ /*@branch For IE6-Win, IE7-Win */ input, button, textarea, select { *font-size: 100%; } minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/css/toc.css000066400000000000000000000002331237675341000273210ustar00rootroot00000000000000div#toc ul li { list-style: none; } div#toc ul li ul { margin-bottom: 0.75em; } div#toc ul li ul li ul { margin-bottom: 0.25em; } minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/extern/000077500000000000000000000000001237675341000265415ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/extern/external-lib.js000066400000000000000000000001161237675341000314630ustar00rootroot00000000000000// Preserve testEncoding function function testEncoding(encodedString) {}; minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/index.html000066400000000000000000000125161237675341000272360ustar00rootroot00000000000000 Install Apache

Install Apache

Table of contents

Introduction

The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.

Apache has been the most popular web server on the Internet since April 1996.

The Apache HTTP Server is a project of the Apache Software Foundation.

Download & Unpack

Download and install Apache from http://httpd.apache.org/download.cgi.

Look for the Win32 Binary version.

Install

When you install Apache, you'll get a prompt for Server Information. Here are the settings I've used:

Apache Server Information

Network Domain
localhost
Server Name
localhost
Admin Email
(your any email)

I recommend you to check for All Users, on Port 80, as a Service.

Path notes

If you choose Typical setup and C:\apache as your installation folder, it'll actually be installed to C:\apache\Apache2.

In Custom setup you can specifically choose where to install each of it's parts/sub-parts.

if you are updating from a previous version of 2.x, you will have to uninstall the old version before installing the new one.
However, Apache 2.x will play very nicely with an older Apache 1.x version.

Starting / Stopping Apache

After installing, Apache2 will automatically start.

You can easily start | stop | restart Apache and Apache2 via that icon in your system tray.

If you get the The requested operation has failed! error while starting apache try the Test Configuration shortcut in the Start Menu to find the error (if the console window pops up and closes before you can read it, it means that your configuration is fine).

Testing

Now the ultimate test to see if it's all working.

Open your browser and head to http://127.0.0.1/ or http://localhost/.

Apache Installed

If you see the above Apache installation's test page then you have your server configured and running.

Making Apache point to your files

  1. Using a text editor open C:\<APACHE_INSTALLATION_FOLDER>\conf\httpd.conf (in the start-menu there should also be a Edit the Apache httpd.conf Configuration File shortcut) and search for DocumentRoot.
  2. Change it from something like DocumentRoot C:/<APACHE_INSTALLATION_FOLDER>/htdocs to the location where your HTML files are located (e.g. DocumentRoot C:/public_html).
  3. Then scroll down about one page and change <Directory "C:/<APACHE_INSTALLATION_FOLDER>/htdocs"> to point to the same location you set DocumentRoot to in the last step.
  4. Restart apache so the changes take effect.
minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/js/000077500000000000000000000000001237675341000256505ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/js/samaxesjs.core.js000066400000000000000000000015701237675341000311360ustar00rootroot00000000000000/* * samaxesJS JavaScript Library * TOC JavaScript Control v@VERSION * http://code.google.com/p/samaxesjs/ * * Copyright (c) 2008 samaxes.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * The samaxesJS global namespace object. */ var samaxesJS = function() {}; try { testEncoding('你好,中文测试'); } catch (e) { } minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/js/subdir/000077500000000000000000000000001237675341000271405ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/demo/src/main/webapp/js/subdir/samaxesjs.toc.js000066400000000000000000000054531237675341000322670ustar00rootroot00000000000000/* * The TOC control dynamically builds a table of contents from the headings in * a document and prepends legal-style section numbers to each of the headings. */ samaxesJS.toc = function() { var window = this, document = this.document; /* * Create TOC element links. */ function createLink(nodeId, innerHTML) { var a = document.createElement('a'); if (nodeId !== '') { a.setAttribute('href', '#' + nodeId); } a.innerHTML = innerHTML; return a; } /* * Logging and debugging. */ function debug(object) { if (window.console && window.console.log) { window.console.log(object); } } return function(toc) { toc = toc.appendChild(document.createElement('ul')); var i2 = 0, i3 = 0, i4 = 0; var nodes = document.body.childNodes; for (var i = 0; i < nodes.length; ++i) { var node = nodes[i]; var tagName = node.nodeName.toLowerCase(); var section; try { if (tagName === 'h4') { ++i4; if (i4 === 1) { toc.lastChild.lastChild.lastChild.appendChild(document.createElement('ul')); } section = i2 + '.' + i3 + '.' + i4; node.insertBefore(document.createTextNode(section + '. '), node.firstChild); toc.lastChild.lastChild.lastChild.lastChild.appendChild(document.createElement('li')).appendChild( createLink(node.id, node.innerHTML)); } else if (tagName === 'h3') { ++i3; i4 = 0; if (i3 === 1) { toc.lastChild.appendChild(document.createElement('ul')); } section = i2 + '.' + i3; node.insertBefore(document.createTextNode(section + '. '), node.firstChild); toc.lastChild.lastChild.appendChild(document.createElement('li')).appendChild( createLink(node.id, node.innerHTML)); } else if (tagName === 'h2') { ++i2; i3 = 0; i4 = 0; section = i2; node.insertBefore(document.createTextNode(section + '. '), node.firstChild); toc.appendChild(document.createElement('li')).appendChild(createLink(node.id, node.innerHTML)); } } catch (error) { debug('Error message: ' + error.message); } } }; }(); // Export the symbols you want to keep when using a CompilationLevel of ADVANCED_OPTIMIZATIONS window['samaxesJS'] = samaxesJS; samaxesJS['toc'] = samaxesJS.toc; minify-maven-plugin-minify-maven-plugin-1.7.4/pom.xml000066400000000000000000000263451237675341000226460ustar00rootroot00000000000000 4.0.0 org.sonatype.oss oss-parent 9 com.samaxes.maven minify-maven-plugin 1.7.4 maven-plugin Minify Maven Plugin Combine and minimize JavaScript and CSS files for faster page loading. https://github.com/samaxes/minify-maven-plugin 2009 samaxes http://www.samaxes.com/ The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo samaxes Samuel Santos http://www.samaxes.com/ Project Owner Developer 0 GitHub https://github.com/samaxes/minify-maven-plugin/issues scm:git:git://github.com/samaxes/minify-maven-plugin.git scm:git:git@github.com:samaxes/minify-maven-plugin.git https://github.com/samaxes/minify-maven-plugin 3.0 org.eclipse.m2e lifecycle-mapping 1.0.0 org.apache.maven.plugins maven-docck-plugin [1.0,) check org.apache.maven.plugins maven-docck-plugin 1.0 check org.apache.maven.plugins maven-compiler-plugin 3.1 ${maven.compiler.source} ${maven.compiler.target} ${project.build.sourceEncoding} org.apache.maven.plugins maven-jar-plugin 2.5 true Samuel Santos false org.apache.maven.plugins maven-plugin-plugin ${maven.plugin.version} ${project.build.sourceEncoding} true mojo-descriptor descriptor org.apache.maven.plugins maven-site-plugin 3.4 org.apache.maven.plugins maven-release-plugin com.github.github site-maven-plugin 0.9 Creating site for ${project.version} true site site org.apache.maven maven-plugin-api 3.2.3 provided org.apache.maven.plugin-tools maven-plugin-annotations 3.3 provided com.yahoo.platform.yui yuicompressor 2.4.7 true com.google.javascript closure-compiler v20140814 true org.apache.maven.plugins maven-project-info-reports-plugin 2.7 dependencies dependency-convergence dependency-management issue-tracking plugin-management license plugins summary project-team scm org.apache.maven.plugins maven-javadoc-plugin 2.9.1 ${project.build.sourceEncoding} ${project.build.sourceEncoding} ${project.build.sourceEncoding} ${maven.compiler.source} true true http://docs.oracle.com/javaee/5/api/ org.apache.maven.plugins maven-jxr-plugin 2.4 ${project.build.sourceEncoding} ${project.build.sourceEncoding} target/site/apidocs org.apache.maven.plugins maven-plugin-plugin ${maven.plugin.version} ${project.build.sourceEncoding} github 1.7 1.7 3.3 true minify-maven-plugin-minify-maven-plugin-1.7.4/src/000077500000000000000000000000001237675341000221065ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/000077500000000000000000000000001237675341000230325ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/000077500000000000000000000000001237675341000237535ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/000077500000000000000000000000001237675341000245315ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/samaxes/000077500000000000000000000000001237675341000261725ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/samaxes/maven/000077500000000000000000000000001237675341000273005ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/samaxes/maven/minify/000077500000000000000000000000001237675341000305735ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/samaxes/maven/minify/common/000077500000000000000000000000001237675341000320635ustar00rootroot00000000000000ClosureConfig.java000066400000000000000000000100301237675341000354030ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/samaxes/maven/minify/common/* * Minify Maven Plugin * https://github.com/samaxes/minify-maven-plugin * * Copyright (c) 2009 samaxes.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.samaxes.maven.minify.common; import java.util.List; import com.google.javascript.jscomp.CompilationLevel; import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import com.google.javascript.jscomp.DependencyOptions; import com.google.javascript.jscomp.SourceFile; import com.google.javascript.jscomp.SourceMap; import com.google.javascript.jscomp.SourceMap.Format; /** * Google Closure Compiler configuration. */ public class ClosureConfig { private final LanguageMode language; private final CompilationLevel compilationLevel; private final DependencyOptions dependencyOptions; private final List externs; private final Boolean useDefaultExterns; private final Format sourceMapFormat; private final Boolean angularPass; /** * Init Closure Compiler values. * * @param language the version of ECMAScript used to report errors in the code * @param compilationLevel the degree of compression and optimization to apply to JavaScript * @param dependencyOptions options for how to manage dependencies between input files * @param externs preserve symbols that are defined outside of the code you are compiling * @param useDefaultExterns use default externs packed with the Closure Compiler * @param createSourceMap create a source map for the minifed/combined production files * @param angularPass use {@code @ngInject} annotation to generate Angular injections */ public ClosureConfig(LanguageMode language, CompilationLevel compilationLevel, DependencyOptions dependencyOptions, List externs, boolean useDefaultExterns, boolean createSourceMap, boolean angularPass) { this.language = language; this.compilationLevel = compilationLevel; this.dependencyOptions = dependencyOptions; this.externs = externs; this.useDefaultExterns = useDefaultExterns; this.sourceMapFormat = (createSourceMap) ? SourceMap.Format.V3 : null; this.angularPass = angularPass; } /** * Gets the language. * * @return the language */ public LanguageMode getLanguage() { return language; } /** * Gets the compilationLevel. * * @return the compilationLevel */ public CompilationLevel getCompilationLevel() { return compilationLevel; } /** * Gets the dependencyOptions. * * @return the dependencyOptions */ public DependencyOptions getDependencyOptions() { return dependencyOptions; } /** * Gets the externs. * * @return the externs */ public List getExterns() { return externs; } /** * Gets the useDefaultExterns. * * @return the useDefaultExterns */ public Boolean getUseDefaultExterns() { return useDefaultExterns; } /** * Gets the sourceMapFormat. * * @return the sourceMapFormat */ public Format getSourceMapFormat() { return sourceMapFormat; } /** * Gets the angularPass. * * @return the angularPass */ public Boolean getAngularPass() { return angularPass; } } JavaScriptErrorReporter.java000066400000000000000000000122621237675341000374550ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/samaxes/maven/minify/common/* * Minify Maven Plugin * https://github.com/samaxes/minify-maven-plugin * * Copyright (c) 2009 samaxes.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.samaxes.maven.minify.common; import org.apache.maven.plugin.logging.Log; import org.mozilla.javascript.ErrorReporter; import org.mozilla.javascript.EvaluatorException; /** * A Rhino compatible error reporter. */ public class JavaScriptErrorReporter implements ErrorReporter { private Log log; private String filename; /** * Error reporter constructor. * * @param log Maven plugin log * @param filename JavaScript source file name */ public JavaScriptErrorReporter(Log log, String filename) { this.log = log; this.filename = filename; } /** * Reports a warning. * * @param message a String describing the warning * @param sourceName a String describing the JavaScript source where the warning occurred; typically a file name or * URL * @param line the line number associated with the warning * @param lineSource the text of the line (may be null) * @param lineOffset the offset into lineSource where problem was detected */ @Override public void warning(String message, String sourceName, int line, String lineSource, int lineOffset) { log.warn(constructMessage(message, sourceName, line, lineSource, lineOffset)); } /** * Reports an error. If execution has not yet begun, the JavaScript engine is free to find additional errors rather * than terminating the translation. However, it will not execute a script that had errors. * * @param message a String describing the warning * @param sourceName a String describing the JavaScript source where the warning occurred; typically a file name or * URL * @param line the line number associated with the warning * @param lineSource the text of the line (may be null) * @param lineOffset the offset into lineSource where problem was detected */ @Override public void error(String message, String sourceName, int line, String lineSource, int lineOffset) { log.error(constructMessage(message, sourceName, line, lineSource, lineOffset)); } /** * Creates an EvaluatorException that may be thrown. runtimeErrors, unlike errors, will always terminate the current * script. * * @param message a String describing the warning * @param sourceName a String describing the JavaScript source where the warning occurred; typically a file name or * URL * @param line the line number associated with the warning * @param lineSource the text of the line (may be null) * @param lineOffset the offset into lineSource where problem was detected */ @Override public EvaluatorException runtimeError(String message, String sourceName, int line, String lineSource, int lineOffset) { log.error(message); return new EvaluatorException(message, sourceName, line, lineSource, lineOffset); } private String constructMessage(String message, String sourceName, int line, String lineSource, int lineOffset) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(message).append(" at "); if (sourceName != null) { stringBuilder.append(sourceName); } else if (filename != null) { stringBuilder.append(filename); } else { stringBuilder.append("(unknown source)"); } stringBuilder.append(" line "); if (line > 0) { stringBuilder.append(line); } else { stringBuilder.append("(unknown line)"); } stringBuilder.append(":"); if (lineOffset >= 0) { stringBuilder.append(lineOffset); } else { stringBuilder.append("(unknown column)"); } if (lineSource != null) { stringBuilder.append('\n'); stringBuilder.append(lineSource); if (lineOffset >= 0 && lineOffset <= lineSource.length()) { stringBuilder.append('\n'); for (int i = 0; i < lineOffset; i++) { char c = lineSource.charAt(i); if (Character.isWhitespace(c)) { stringBuilder.append(c); } else { stringBuilder.append(' '); } } stringBuilder.append("^\n"); } } return stringBuilder.toString(); } } SourceFilesEnumeration.java000066400000000000000000000060351237675341000373050ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/samaxes/maven/minify/common/* * Minify Maven Plugin * https://github.com/samaxes/minify-maven-plugin * * Copyright (c) 2009 samaxes.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.samaxes.maven.minify.common; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.Enumeration; import java.util.List; import java.util.NoSuchElementException; import org.apache.maven.plugin.logging.Log; /** * Used to initialize a {@code SequenceInputStream} with a {@code Enumeration}. The input streams * that are produced by the enumeration will be read, in order, to provide the bytes to be read from the * {@code SequenceInputStream}. */ public class SourceFilesEnumeration implements Enumeration { private List files; private int current = 0; /** * Enumeration public constructor. * * @param log Maven plugin log * @param files list of files * @param verbose show source file paths in log output */ public SourceFilesEnumeration(Log log, List files, boolean verbose) { this.files = files; for (File file : files) { log.info("Processing source file [" + ((verbose) ? file.getPath() : file.getName()) + "]."); } } /** * Tests if this enumeration contains more elements. * * @return {@code true} if and only if this enumeration object contains at least one more element to provide; * {@code false} otherwise. */ @Override public boolean hasMoreElements() { return (current < files.size()) ? true : false; } /** * Returns the next element of this enumeration if this enumeration object has at least one more element to provide. * * @return the next element of this enumeration. * @exception NoSuchElementException if no more elements exist. */ @Override public InputStream nextElement() { InputStream is = null; if (!hasMoreElements()) { throw new NoSuchElementException("No more files!"); } else { File nextElement = files.get(current); current++; try { is = new FileInputStream(nextElement); } catch (FileNotFoundException e) { throw new NoSuchElementException("The path [" + nextElement.getPath() + "] cannot be found."); } } return is; } } YuiConfig.java000066400000000000000000000044361237675341000345520ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/samaxes/maven/minify/common/* * Minify Maven Plugin * https://github.com/samaxes/minify-maven-plugin * * Copyright (c) 2009 samaxes.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.samaxes.maven.minify.common; /** * YUI Compressor configuration. */ public class YuiConfig { private final int lineBreak; private final boolean munge; private final boolean preserveSemicolons; private final boolean disableOptimizations; /** * Init YuiConfig values. * * @param lineBreak split long lines after a specific column * @param munge obfuscate local symbols * @param preserveSemicolons preserve unnecessary semicolons * @param disableOptimizations disable all the built-in micro-optimizations */ public YuiConfig(int lineBreak, boolean munge, boolean preserveSemicolons, boolean disableOptimizations) { this.lineBreak = lineBreak; this.munge = munge; this.preserveSemicolons = preserveSemicolons; this.disableOptimizations = disableOptimizations; } /** * Gets the lineBreak. * * @return the lineBreak */ public int getLineBreak() { return lineBreak; } /** * Gets the munge. * * @return the munge */ public boolean isMunge() { return munge; } /** * Gets the preserveSemicolons. * * @return the preserveSemicolons */ public boolean isPreserveSemicolons() { return preserveSemicolons; } /** * Gets the disableOptimizations. * * @return the disableOptimizations */ public boolean isDisableOptimizations() { return disableOptimizations; } } minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/samaxes/maven/minify/plugin/000077500000000000000000000000001237675341000320715ustar00rootroot00000000000000MinifyMojo.java000066400000000000000000000475761237675341000347600ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/samaxes/maven/minify/plugin/* * Minify Maven Plugin * https://github.com/samaxes/minify-maven-plugin * * Copyright (c) 2009 samaxes.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.samaxes.maven.minify.plugin; import java.io.File; import java.io.FileNotFoundException; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import com.google.common.base.Strings; import com.google.javascript.jscomp.CompilationLevel; import com.google.javascript.jscomp.CompilerOptions.LanguageMode; import com.google.javascript.jscomp.DependencyOptions; import com.google.javascript.jscomp.SourceFile; import com.samaxes.maven.minify.common.ClosureConfig; import com.samaxes.maven.minify.common.YuiConfig; /** * Goal for combining and minifying CSS and JavaScript files. */ @Mojo(name = "minify", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, threadSafe = true) public class MinifyMojo extends AbstractMojo { /** * Engine used for minification */ public static enum Engine { /** YUI Compressor */ YUI, /** Google Closure Compiler */ CLOSURE; } /* ************** */ /* Global Options */ /* ************** */ /** * Show source file paths in log output. * * @since 1.5.2 * @deprecated Use {@link #verbose} instead. */ @Deprecated @Parameter(property = "debug") private Boolean debug; /** * Display additional informational messages and warnings. */ @Parameter(property = "verbose", defaultValue = "false") private boolean verbose; /** * Size of the buffer used to read source files. */ @Parameter(property = "bufferSize", defaultValue = "4096") private int bufferSize; /** * If a supported character set is specified, it will be used to read the input file. Otherwise, it will assume that * the platform's default character set is being used. The output file is encoded using the same character set.
* See the IANA Charset Registry for a list of valid * encoding types. * * @since 1.3.2 */ @Parameter(property = "charset", defaultValue = "${project.build.sourceEncoding}") private String charset; /** * The output file name suffix. * * @since 1.3.2 */ @Parameter(property = "suffix", defaultValue = "min") private String suffix; /** * Do not append a suffix to the minified output file name, independently of the value in the {@code suffix} * parameter.
* Warning: when both the options {@code nosuffix} and {@code skipMerge} are set to {@code true}, * the plugin execution phase needs to be set to {@code package}, otherwise the output files will be overridden by * the source files during the packaging. * * @since 1.7 */ @Parameter(property = "nosuffix", defaultValue = "false") private boolean nosuffix; /** * Skip the merge step. Minification will be applied to each source file individually. * * @since 1.5.2 */ @Parameter(property = "skipMerge", defaultValue = "false") private boolean skipMerge; /** * Skip the minify step. Useful when merging files that are already minified. * * @since 1.5.2 */ @Parameter(property = "skipMinify", defaultValue = "false") private boolean skipMinify; /** * Webapp source directory. */ @Parameter(property = "webappSourceDir", defaultValue = "${basedir}/src/main/webapp") private String webappSourceDir; /** * Webapp target directory. */ @Parameter(property = "webappTargetDir", defaultValue = "${project.build.directory}/${project.build.finalName}") private String webappTargetDir; /* *********** */ /* CSS Options */ /* *********** */ /** * CSS source directory. */ @Parameter(property = "cssSourceDir", defaultValue = "css") private String cssSourceDir; /** * CSS source file names list. */ @Parameter(property = "cssSourceFiles", alias = "cssFiles") private ArrayList cssSourceFiles; /** * CSS files to include. Specified as fileset patterns which are relative to the CSS source directory. * * @since 1.2 */ @Parameter(property = "cssSourceIncludes", alias = "cssIncludes") private ArrayList cssSourceIncludes; /** * CSS files to exclude. Specified as fileset patterns which are relative to the CSS source directory. * * @since 1.2 */ @Parameter(property = "cssSourceExcludes", alias = "cssExcludes") private ArrayList cssSourceExcludes; /** * CSS target directory. Takes the same value as {@code cssSourceDir} when empty. * * @since 1.3.2 */ @Parameter(property = "cssTargetDir") private String cssTargetDir; /** * CSS output file name. */ @Parameter(property = "cssFinalFile", defaultValue = "style.css") private String cssFinalFile; /** * Define the CSS compressor engine to use.
* Possible values are: * * * @since 1.7.1 */ @Parameter(property = "cssEngine", defaultValue = "YUI") private Engine cssEngine; /* ****************** */ /* JavaScript Options */ /* ****************** */ /** * JavaScript source directory. */ @Parameter(property = "jsSourceDir", defaultValue = "js") private String jsSourceDir; /** * JavaScript source file names list. */ @Parameter(property = "jsSourceFiles", alias = "jsFiles") private ArrayList jsSourceFiles; /** * JavaScript files to include. Specified as fileset patterns which are relative to the JavaScript source directory. * * @since 1.2 */ @Parameter(property = "jsSourceIncludes", alias = "jsIncludes") private ArrayList jsSourceIncludes; /** * JavaScript files to exclude. Specified as fileset patterns which are relative to the JavaScript source directory. * * @since 1.2 */ @Parameter(property = "jsSourceExcludes", alias = "jsExcludes") private ArrayList jsSourceExcludes; /** * JavaScript target directory. Takes the same value as {@code jsSourceDir} when empty. * * @since 1.3.2 */ @Parameter(property = "jsTargetDir") private String jsTargetDir; /** * JavaScript output file name. */ @Parameter(property = "jsFinalFile", defaultValue = "script.js") private String jsFinalFile; /** * Define the JavaScript compressor engine to use.
* Possible values are: * * * @since 1.6 */ @Parameter(property = "jsEngine", defaultValue = "YUI") private Engine jsEngine; /* *************************** */ /* YUI Compressor Only Options */ /* *************************** */ /** * Some source control tools don't like files containing lines longer than, say 8000 characters. The line-break * option is used in that case to split long lines after a specific column. It can also be used to make the code * more readable and easier to debug. Specify {@code 0} to get a line break after each semi-colon in JavaScript, and * after each rule in CSS. Specify {@code -1} to disallow line breaks. * * @deprecated Use {@link #yuiLineBreak} instead. */ @Deprecated @Parameter(property = "linebreak") private Integer linebreak; /** * Some source control tools don't like files containing lines longer than, say 8000 characters. The line-break * option is used in that case to split long lines after a specific column. It can also be used to make the code * more readable and easier to debug. Specify {@code 0} to get a line break after each semi-colon in JavaScript, and * after each rule in CSS. Specify {@code -1} to disallow line breaks. */ @Parameter(property = "yuiLineBreak", defaultValue = "-1") private int yuiLineBreak; /** * Obfuscate local symbols in addition to minification. * * @deprecated Use {@link #yuiNoMunge} instead. */ @Deprecated @Parameter(property = "munge") private Boolean munge; /** * Minify only. Do not obfuscate local symbols. */ @Parameter(property = "yuiNoMunge", defaultValue = "false") private boolean yuiNoMunge; /** * Preserve unnecessary semicolons (such as right before a '}'). This option is useful when compressed code has to * be run through JSLint. * * @deprecated Use {@link #yuiPreserveSemicolons} instead. */ @Deprecated @Parameter(property = "preserveAllSemiColons") private Boolean preserveAllSemiColons; /** * Preserve unnecessary semicolons (such as right before a '}'). This option is useful when compressed code has to * be run through JSLint. */ @Parameter(property = "yuiPreserveSemicolons", defaultValue = "false") private boolean yuiPreserveSemicolons; /** * Disable all the built-in micro-optimizations. * * @deprecated Use {@link #yuiDisableOptimizations} instead. */ @Deprecated @Parameter(property = "disableOptimizations") private Boolean disableOptimizations; /** * Disable all the built-in micro-optimizations. */ @Parameter(property = "yuiDisableOptimizations", defaultValue = "false") private boolean yuiDisableOptimizations; /* ************************************ */ /* Google Closure Compiler Only Options */ /* ************************************ */ /** * Refers to which version of ECMAScript to assume when checking for errors in your code.
* Possible values are: *
    *
  • {@code ECMASCRIPT3}: Checks code assuming ECMAScript 3 compliance, and gives errors for code using features * only present in ECMAScript 5.
  • *
  • {@code ECMASCRIPT5}: Checks code assuming ECMAScript 5 compliance, allowing new features not present in * ECMAScript 3.
  • *
  • {@code ECMASCRIPT5_STRICT}: Like {@code ECMASCRIPT5} but assumes compliance with strict mode ('use strict';). *
  • *
* * @since 1.7.2 */ @Parameter(property = "closureLanguageIn", defaultValue = "ECMASCRIPT3") private LanguageMode closureLanguage; /** * The degree of compression and optimization to apply to your JavaScript.
* There are three possible compilation levels: *
    *
  • {@code WHITESPACE_ONLY}: Just removes whitespace and comments from your JavaScript.
  • *
  • {@code SIMPLE_OPTIMIZATIONS}: Performs compression and optimization that does not interfere with the * interaction between the compiled JavaScript and other JavaScript. This level renames only local variables.
  • *
  • {@code ADVANCED_OPTIMIZATIONS}: Achieves the highest level of compression by renaming symbols in your * JavaScript. When using {@code ADVANCED_OPTIMIZATIONS} compilation you must perform extra steps to preserve * references to external symbols. See Advanced Compilation and * Externs for more information about {@code ADVANCED_OPTIMIZATIONS}.
  • *
* * @since 1.7.2 */ @Parameter(property = "closureCompilationLevel", defaultValue = "SIMPLE_OPTIMIZATIONS") private CompilationLevel closureCompilationLevel; /** * List of JavaScript files containing code that declares function names or other symbols. Use * {@code closureExterns} to preserve symbols that are defined outside of the code you are compiling. The * {@code closureExterns} parameter only has an effect if you are using a {@code CompilationLevel} of * {@code ADVANCED_OPTIMIZATIONS}.
* These file names are relative to {@link #webappSourceDir} directory. * * @since 1.7.2 */ @Parameter(property = "closureExterns") private ArrayList closureExterns; /** *

* Use default externs provided with Closure Compiler. *

*

* For the complete list of externs please visit:
* https://github.com/google/closure- * compiler/tree/master/externs *

* * @since 1.7.4 */ @Parameter(property = "closureUseDefaultExterns", defaultValue = "false") private boolean closureUseDefaultExterns; /** *

* Collects information mapping the generated (compiled) source back to its original source for debugging purposes. *

*

* Please visit Source Map Revision 3 * Proposal for more information. *

* * @since 1.7.3 */ @Parameter(property = "closureCreateSourceMap", defaultValue = "false") private boolean closureCreateSourceMap; /** *

* Enables or disables sorting mode for Closure Library dependencies. *

*

* If true, automatically sort dependencies so that a file that {@code goog.provides} symbol X will always come * before a file that {@code goog.requires} symbol X. *

* * @since 1.7.4 */ @Parameter(property = "closureSortDependencies", defaultValue = "false") private boolean closureSortDependencies; /** * Generate {@code $inject} properties for AngularJS for functions annotated with {@code @ngInject}. * * @since 1.7.3 */ @Parameter(property = "closureAngularPass", defaultValue = "false") private boolean closureAngularPass; /** * Executed when the goal is invoked, it will first invoke a parallel lifecycle, ending at the given phase. */ @Override public void execute() throws MojoExecutionException, MojoFailureException { checkDeprecatedOptions(); if (skipMerge && skipMinify) { getLog().warn("Both merge and minify steps are configured to be skipped."); return; } fillOptionalValues(); YuiConfig yuiConfig = fillYuiConfig(); ClosureConfig closureConfig = fillClosureConfig(); Collection processFilesTasks = new ArrayList(); try { processFilesTasks.add(new ProcessCSSFilesTask(getLog(), debug, bufferSize, charset, suffix, nosuffix, skipMerge, skipMinify, webappSourceDir, webappTargetDir, cssSourceDir, cssSourceFiles, cssSourceIncludes, cssSourceExcludes, cssTargetDir, cssFinalFile, cssEngine, yuiConfig)); processFilesTasks.add(new ProcessJSFilesTask(getLog(), debug, bufferSize, charset, suffix, nosuffix, skipMerge, skipMinify, webappSourceDir, webappTargetDir, jsSourceDir, jsSourceFiles, jsSourceIncludes, jsSourceExcludes, jsTargetDir, jsFinalFile, jsEngine, yuiConfig, closureConfig)); } catch (FileNotFoundException e) { throw new MojoFailureException(e.getMessage(), e); } ExecutorService executor = Executors.newFixedThreadPool(2); try { List> futures = executor.invokeAll(processFilesTasks); for (Future future : futures) { try { future.get(); } catch (ExecutionException e) { throw new MojoExecutionException(e.getMessage(), e); } } executor.shutdown(); } catch (InterruptedException e) { executor.shutdownNow(); throw new MojoExecutionException(e.getMessage(), e); } } private void checkDeprecatedOptions() { if (debug == null) { debug = verbose; } else { getLog().warn( "The option 'debug' is deprecated and will be removed on the next version. Use 'verbose' instead."); } if (linebreak == null) { linebreak = yuiLineBreak; } else { getLog().warn( "The option 'linebreak' is deprecated and will be removed on the next version. Use 'yuiLineBreak' instead."); } if (munge == null) { munge = !yuiNoMunge; } else { getLog().warn( "The option 'munge' is deprecated and will be removed on the next version. Use 'yuiNoMunge' instead."); } if (preserveAllSemiColons == null) { preserveAllSemiColons = yuiPreserveSemicolons; } else { getLog().warn( "The option 'preserveAllSemiColons' is deprecated and will be removed on the next version. Use 'yuiPreserveSemicolons' instead."); } if (disableOptimizations == null) { disableOptimizations = yuiDisableOptimizations; } else { getLog().warn( "The option 'disableOptimizations' is deprecated and will be removed on the next version. Use 'yuiDisableOptimizations' instead."); } } private void fillOptionalValues() { if (Strings.isNullOrEmpty(cssTargetDir)) { cssTargetDir = cssSourceDir; } if (Strings.isNullOrEmpty(jsTargetDir)) { jsTargetDir = jsSourceDir; } if (Strings.isNullOrEmpty(charset)) { charset = Charset.defaultCharset().name(); } } private YuiConfig fillYuiConfig() { return new YuiConfig(linebreak, munge, preserveAllSemiColons, disableOptimizations); } private ClosureConfig fillClosureConfig() { DependencyOptions dependencyOptions = new DependencyOptions(); dependencyOptions.setDependencySorting(closureSortDependencies); List externs = new ArrayList<>(); for (String extern : closureExterns) { externs.add(SourceFile.fromFile(webappSourceDir + File.separator + extern, Charset.forName(charset))); } return new ClosureConfig(closureLanguage, closureCompilationLevel, dependencyOptions, externs, closureUseDefaultExterns, closureCreateSourceMap, closureAngularPass); } } ProcessCSSFilesTask.java000066400000000000000000000115161237675341000364560ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/samaxes/maven/minify/plugin/* * Minify Maven Plugin * https://github.com/samaxes/minify-maven-plugin * * Copyright (c) 2009 samaxes.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.samaxes.maven.minify.plugin; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.util.List; import org.apache.maven.plugin.logging.Log; import com.samaxes.maven.minify.common.YuiConfig; import com.samaxes.maven.minify.plugin.MinifyMojo.Engine; import com.yahoo.platform.yui.compressor.CssCompressor; /** * Task for merging and compressing CSS files. */ public class ProcessCSSFilesTask extends ProcessFilesTask { /** * Task constructor. * * @param log Maven plugin log * @param verbose display additional info * @param bufferSize size of the buffer used to read source files * @param charset if a character set is specified, a byte-to-char variant allows the encoding to be selected. * Otherwise, only byte-to-byte operations are used * @param suffix final file name suffix * @param nosuffix whether to use a suffix for the minified file name or not * @param skipMerge whether to skip the merge step or not * @param skipMinify whether to skip the minify step or not * @param webappSourceDir web resources source directory * @param webappTargetDir web resources target directory * @param inputDir directory containing source files * @param sourceFiles list of source files to include * @param sourceIncludes list of source files to include * @param sourceExcludes list of source files to exclude * @param outputDir directory to write the final file * @param outputFilename the output file name * @param engine minify processor engine selected * @param yuiConfig YUI Compressor configuration * @throws FileNotFoundException when the given source file does not exist */ public ProcessCSSFilesTask(Log log, boolean verbose, Integer bufferSize, String charset, String suffix, boolean nosuffix, boolean skipMerge, boolean skipMinify, String webappSourceDir, String webappTargetDir, String inputDir, List sourceFiles, List sourceIncludes, List sourceExcludes, String outputDir, String outputFilename, Engine engine, YuiConfig yuiConfig) throws FileNotFoundException { super(log, verbose, bufferSize, charset, suffix, nosuffix, skipMerge, skipMinify, webappSourceDir, webappTargetDir, inputDir, sourceFiles, sourceIncludes, sourceExcludes, outputDir, outputFilename, engine, yuiConfig); } /** * Minifies a CSS file. * * @param mergedFile input file resulting from the merged step * @param minifiedFile output file resulting from the minify step * @throws IOException when the minify step fails */ @Override protected void minify(File mergedFile, File minifiedFile) throws IOException { try (InputStream in = new FileInputStream(mergedFile); OutputStream out = new FileOutputStream(minifiedFile); InputStreamReader reader = new InputStreamReader(in, charset); OutputStreamWriter writer = new OutputStreamWriter(out, charset)) { log.info("Creating the minified file [" + ((verbose) ? minifiedFile.getPath() : minifiedFile.getName()) + "]."); switch (engine) { case YUI: log.debug("Using YUI Compressor engine."); CssCompressor compressor = new CssCompressor(reader); compressor.compress(writer, yuiConfig.getLineBreak()); break; default: log.warn("CSS engine not supported."); break; } } catch (IOException e) { log.error("Failed to compress the CSS file [" + ((verbose) ? mergedFile.getPath() : mergedFile.getName()) + "].", e); throw e; } logCompressionGains(mergedFile, minifiedFile); } } ProcessFilesTask.java000066400000000000000000000315451237675341000361110ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/samaxes/maven/minify/plugin/* * Minify Maven Plugin * https://github.com/samaxes/minify-maven-plugin * * Copyright (c) 2009 samaxes.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.samaxes.maven.minify.plugin; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.SequenceInputStream; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.concurrent.Callable; import java.util.zip.GZIPOutputStream; import org.apache.maven.plugin.logging.Log; import org.codehaus.plexus.util.DirectoryScanner; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import com.samaxes.maven.minify.common.SourceFilesEnumeration; import com.samaxes.maven.minify.common.YuiConfig; import com.samaxes.maven.minify.plugin.MinifyMojo.Engine; /** * Abstract class for merging and compressing a files list. */ public abstract class ProcessFilesTask implements Callable { public static final String TEMP_SUFFIX = ".tmp"; protected final Log log; protected final boolean verbose; protected final Integer bufferSize; protected final String charset; protected final String suffix; protected final boolean nosuffix; protected final boolean skipMerge; protected final boolean skipMinify; protected final Engine engine; protected final YuiConfig yuiConfig; private final File sourceDir; private final File targetDir; private final String mergedFilename; private final List files = new ArrayList(); private final boolean sourceFilesEmpty; private final boolean sourceIncludesEmpty; /** * Task constructor. * * @param log Maven plugin log * @param verbose display additional info * @param bufferSize size of the buffer used to read source files * @param charset if a character set is specified, a byte-to-char variant allows the encoding to be selected. * Otherwise, only byte-to-byte operations are used * @param suffix final file name suffix * @param nosuffix whether to use a suffix for the minified file name or not * @param skipMerge whether to skip the merge step or not * @param skipMinify whether to skip the minify step or not * @param webappSourceDir web resources source directory * @param webappTargetDir web resources target directory * @param inputDir directory containing source files * @param sourceFiles list of source files to include * @param sourceIncludes list of source files to include * @param sourceExcludes list of source files to exclude * @param outputDir directory to write the final file * @param outputFilename the output file name * @param engine minify processor engine selected * @param yuiConfig YUI Compressor configuration * @throws FileNotFoundException when the given source file does not exist */ public ProcessFilesTask(Log log, boolean verbose, Integer bufferSize, String charset, String suffix, boolean nosuffix, boolean skipMerge, boolean skipMinify, String webappSourceDir, String webappTargetDir, String inputDir, List sourceFiles, List sourceIncludes, List sourceExcludes, String outputDir, String outputFilename, Engine engine, YuiConfig yuiConfig) throws FileNotFoundException { this.log = log; this.verbose = verbose; this.bufferSize = bufferSize; this.charset = charset; this.suffix = suffix + "."; this.nosuffix = nosuffix; this.skipMerge = skipMerge; this.skipMinify = skipMinify; this.engine = engine; this.yuiConfig = yuiConfig; this.sourceDir = new File(webappSourceDir + File.separator + inputDir); this.targetDir = new File(webappTargetDir + File.separator + outputDir); this.mergedFilename = outputFilename; for (String sourceFilename : sourceFiles) { addNewSourceFile(mergedFilename, sourceFilename); } for (File sourceInclude : getFilesToInclude(sourceIncludes, sourceExcludes)) { if (!files.contains(sourceInclude)) { addNewSourceFile(mergedFilename, sourceInclude); } } this.sourceFilesEmpty = sourceFiles.isEmpty(); this.sourceIncludesEmpty = sourceIncludes.isEmpty(); } /** * Method executed by the thread. * * @throws IOException when the merge or minify steps fail */ @Override public Object call() throws IOException { synchronized (log) { String fileType = (this instanceof ProcessCSSFilesTask) ? "CSS" : "JavaScript"; log.info("Starting " + fileType + " task:"); if (!files.isEmpty() && (targetDir.exists() || targetDir.mkdirs())) { if (skipMerge) { log.info("Skipping the merge step..."); String sourceBasePath = sourceDir.getAbsolutePath(); for (File mergedFile : files) { // Create folders to preserve sub-directory structure when only minifying String originalPath = mergedFile.getAbsolutePath(); String subPath = originalPath.substring(sourceBasePath.length(), originalPath.lastIndexOf(File.separator)); File targetPath = new File(targetDir.getAbsolutePath() + subPath); targetPath.mkdirs(); File minifiedFile = new File(targetPath, (nosuffix) ? mergedFile.getName() : FileUtils.basename(mergedFile.getName()) + suffix + FileUtils.getExtension(mergedFile.getName())); minify(mergedFile, minifiedFile); } } else if (skipMinify) { File mergedFile = new File(targetDir, mergedFilename); merge(mergedFile); log.info("Skipping the minify step..."); } else { File mergedFile = new File(targetDir, (nosuffix) ? mergedFilename + TEMP_SUFFIX : mergedFilename); merge(mergedFile); File minifiedFile = new File(targetDir, (nosuffix) ? mergedFilename : FileUtils.basename(mergedFilename) + suffix + FileUtils.getExtension(mergedFilename)); minify(mergedFile, minifiedFile); if (nosuffix) { if (!mergedFile.delete()) { mergedFile.deleteOnExit(); } } } log.info(""); } else if (!sourceFilesEmpty || !sourceIncludesEmpty) { // 'files' list will be empty if source file paths or names added to the project's POM are invalid. log.error("No valid " + fileType + " source files found to process."); } } return null; } /** * Merges a list of source files. * * @param mergedFile output file resulting from the merged step * @throws IOException when the merge step fails */ protected void merge(File mergedFile) throws IOException { try (InputStream sequence = new SequenceInputStream(new SourceFilesEnumeration(log, files, verbose)); OutputStream out = new FileOutputStream(mergedFile); InputStreamReader sequenceReader = new InputStreamReader(sequence, charset); OutputStreamWriter outWriter = new OutputStreamWriter(out, charset)) { log.info("Creating the merged file [" + ((verbose) ? mergedFile.getPath() : mergedFile.getName()) + "]."); IOUtil.copy(sequenceReader, outWriter, bufferSize); } catch (IOException e) { log.error("Failed to concatenate files.", e); throw e; } } /** * Minifies a source file. * * @param mergedFile input file resulting from the merged step * @param minifiedFile output file resulting from the minify step * @throws IOException when the minify step fails */ abstract void minify(File mergedFile, File minifiedFile) throws IOException; /** * Logs compression gains. * * @param mergedFile input file resulting from the merged step * @param minifiedFile output file resulting from the minify step */ void logCompressionGains(File mergedFile, File minifiedFile) { try { File temp = File.createTempFile(minifiedFile.getName(), ".gz"); try (InputStream in = new FileInputStream(minifiedFile); OutputStream out = new FileOutputStream(temp); GZIPOutputStream outGZIP = new GZIPOutputStream(out)) { IOUtil.copy(in, outGZIP, bufferSize); } log.info("Uncompressed size: " + mergedFile.length() + " bytes."); log.info("Compressed size: " + minifiedFile.length() + " bytes minified (" + temp.length() + " bytes gzipped)."); temp.deleteOnExit(); } catch (IOException e) { log.debug("Failed to calculate the gzipped file size.", e); } } /** * Logs an addition of a new source file. * * @param finalFilename the final file name * @param sourceFilename the source file name * @throws FileNotFoundException when the given source file does not exist */ private void addNewSourceFile(String finalFilename, String sourceFilename) throws FileNotFoundException { File sourceFile = new File(sourceDir, sourceFilename); addNewSourceFile(finalFilename, sourceFile); } /** * Logs an addition of a new source file. * * @param finalFilename the final file name * @param sourceFile the source file * @throws FileNotFoundException when the given source file does not exist */ private void addNewSourceFile(String finalFilename, File sourceFile) throws FileNotFoundException { if (sourceFile.exists()) { if (finalFilename.equalsIgnoreCase(sourceFile.getName())) { log.warn("The source file [" + ((verbose) ? sourceFile.getPath() : sourceFile.getName()) + "] has the same name as the final file."); } log.debug("Adding source file [" + ((verbose) ? sourceFile.getPath() : sourceFile.getName()) + "]."); files.add(sourceFile); } else { throw new FileNotFoundException("The source file [" + ((verbose) ? sourceFile.getPath() : sourceFile.getName()) + "] does not exist."); } } /** * Returns the files to copy. Default exclusions are used when the excludes list is empty. * * @param includes list of source files to include * @param excludes list of source files to exclude * @return the files to copy */ private List getFilesToInclude(List includes, List excludes) { List includedFiles = new ArrayList(); if (includes != null && !includes.isEmpty()) { DirectoryScanner scanner = new DirectoryScanner(); scanner.setIncludes(includes.toArray(new String[0])); scanner.setExcludes(excludes.toArray(new String[0])); scanner.addDefaultExcludes(); scanner.setBasedir(sourceDir); scanner.scan(); for (String includedFilename : scanner.getIncludedFiles()) { includedFiles.add(new File(sourceDir, includedFilename)); } Collections.sort(includedFiles, new Comparator() { @Override public int compare(File o1, File o2) { return o1.getName().compareToIgnoreCase(o2.getName()); } }); } return includedFiles; } } ProcessJSFilesTask.java000066400000000000000000000212441237675341000363410ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/java/com/samaxes/maven/minify/plugin/* * Minify Maven Plugin * https://github.com/samaxes/minify-maven-plugin * * Copyright (c) 2009 samaxes.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.samaxes.maven.minify.plugin; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.util.List; import org.apache.maven.plugin.logging.Log; import org.mozilla.javascript.EvaluatorException; import com.google.common.collect.Lists; import com.google.javascript.jscomp.CommandLineRunner; import com.google.javascript.jscomp.Compiler; import com.google.javascript.jscomp.CompilerOptions; import com.google.javascript.jscomp.SourceFile; import com.google.javascript.jscomp.SourceMap; import com.samaxes.maven.minify.common.ClosureConfig; import com.samaxes.maven.minify.common.JavaScriptErrorReporter; import com.samaxes.maven.minify.common.YuiConfig; import com.samaxes.maven.minify.plugin.MinifyMojo.Engine; import com.yahoo.platform.yui.compressor.JavaScriptCompressor; /** * Task for merging and compressing JavaScript files. */ public class ProcessJSFilesTask extends ProcessFilesTask { private final ClosureConfig closureConfig; /** * Task constructor. * * @param log Maven plugin log * @param verbose display additional info * @param bufferSize size of the buffer used to read source files * @param charset if a character set is specified, a byte-to-char variant allows the encoding to be selected. * Otherwise, only byte-to-byte operations are used * @param suffix final file name suffix * @param nosuffix whether to use a suffix for the minified file name or not * @param skipMerge whether to skip the merge step or not * @param skipMinify whether to skip the minify step or not * @param webappSourceDir web resources source directory * @param webappTargetDir web resources target directory * @param inputDir directory containing source files * @param sourceFiles list of source files to include * @param sourceIncludes list of source files to include * @param sourceExcludes list of source files to exclude * @param outputDir directory to write the final file * @param outputFilename the output file name * @param engine minify processor engine selected * @param yuiConfig YUI Compressor configuration * @param closureConfig Google Closure Compiler configuration * @throws FileNotFoundException when the given source file does not exist */ public ProcessJSFilesTask(Log log, boolean verbose, Integer bufferSize, String charset, String suffix, boolean nosuffix, boolean skipMerge, boolean skipMinify, String webappSourceDir, String webappTargetDir, String inputDir, List sourceFiles, List sourceIncludes, List sourceExcludes, String outputDir, String outputFilename, Engine engine, YuiConfig yuiConfig, ClosureConfig closureConfig) throws FileNotFoundException { super(log, verbose, bufferSize, charset, suffix, nosuffix, skipMerge, skipMinify, webappSourceDir, webappTargetDir, inputDir, sourceFiles, sourceIncludes, sourceExcludes, outputDir, outputFilename, engine, yuiConfig); this.closureConfig = closureConfig; } /** * Minifies a JavaScript file. * * @param mergedFile input file resulting from the merged step * @param minifiedFile output file resulting from the minify step * @throws IOException when the minify step fails */ @Override protected void minify(File mergedFile, File minifiedFile) throws IOException { try (InputStream in = new FileInputStream(mergedFile); OutputStream out = new FileOutputStream(minifiedFile); InputStreamReader reader = new InputStreamReader(in, charset); OutputStreamWriter writer = new OutputStreamWriter(out, charset)) { log.info("Creating the minified file [" + ((verbose) ? minifiedFile.getPath() : minifiedFile.getName()) + "]."); switch (engine) { case CLOSURE: log.debug("Using Google Closure Compiler engine."); CompilerOptions options = new CompilerOptions(); closureConfig.getCompilationLevel().setOptionsForCompilationLevel(options); options.setOutputCharset(charset); options.setLanguageIn(closureConfig.getLanguage()); options.setAngularPass(closureConfig.getAngularPass()); options.setDependencyOptions(closureConfig.getDependencyOptions()); File sourceMapResult = new File(minifiedFile.getPath() + ".map"); if (closureConfig.getSourceMapFormat() != null) { options.setSourceMapFormat(closureConfig.getSourceMapFormat()); options.setSourceMapOutputPath(sourceMapResult.getPath()); // options.setSourceMapLocationMappings(Lists.newArrayList(new // SourceMap.LocationMapping(sourceDir.getPath() + File.separator, ""))); } SourceFile input = SourceFile.fromInputStream(mergedFile.getName(), in); List externs = closureConfig.getExterns(); if (closureConfig.getUseDefaultExterns()) { externs.addAll(CommandLineRunner.getDefaultExterns()); } Compiler compiler = new Compiler(); compiler.compile(externs, Lists.newArrayList(input), options); if (compiler.hasErrors()) { throw new EvaluatorException(compiler.getErrors()[0].description); } writer.append(compiler.toSource()); if (closureConfig.getSourceMapFormat() != null) { log.info("Creating the minified file map [" + ((verbose) ? sourceMapResult.getPath() : sourceMapResult.getName()) + "]."); sourceMapResult.createNewFile(); flushSourceMap(sourceMapResult, minifiedFile.getName(), compiler.getSourceMap()); writer.append(System.getProperty("line.separator")); writer.append("//# sourceMappingURL=" + sourceMapResult.getName()); } break; case YUI: log.debug("Using YUI Compressor engine."); JavaScriptCompressor compressor = new JavaScriptCompressor(reader, new JavaScriptErrorReporter(log, mergedFile.getName())); compressor.compress(writer, yuiConfig.getLineBreak(), yuiConfig.isMunge(), verbose, yuiConfig.isPreserveSemicolons(), yuiConfig.isDisableOptimizations()); break; default: log.warn("JavaScript engine not supported."); break; } } catch (IOException e) { log.error( "Failed to compress the JavaScript file [" + ((verbose) ? mergedFile.getPath() : mergedFile.getName()) + "].", e); throw e; } logCompressionGains(mergedFile, minifiedFile); } private void flushSourceMap(File sourceMapOutputFile, String minifyFileName, SourceMap sourceMap) { try (FileWriter out = new FileWriter(sourceMapOutputFile)) { sourceMap.appendTo(out, minifyFileName); } catch (IOException e) { log.error("Failed to write the JavaScript Source Map file [" + ((verbose) ? sourceMapOutputFile.getPath() : sourceMapOutputFile.getName()) + "].", e); } } } minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/resources/000077500000000000000000000000001237675341000250445ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/resources/META-INF/000077500000000000000000000000001237675341000262045ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/resources/META-INF/m2e/000077500000000000000000000000001237675341000266675ustar00rootroot00000000000000lifecycle-mapping-metadata.xml000066400000000000000000000006211237675341000344770ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/main/resources/META-INF/m2e minify minify-maven-plugin-minify-maven-plugin-1.7.4/src/site/000077500000000000000000000000001237675341000230525ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/site/apt/000077500000000000000000000000001237675341000236365ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/site/apt/examples/000077500000000000000000000000001237675341000254545ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/site/apt/examples/basic.apt000066400000000000000000000023031237675341000272410ustar00rootroot00000000000000 ------ Basic Configuration ------ Samuel Santos ------ 2013-09-08 ------ Basic Configuration The only requirement for Minify Maven Plugin to run is to have source files to process. +---+ com.samaxes.maven minify-maven-plugin 1.7.4 default-minify file-1.css file-n.css file-1.js file-n.js minify +---+ minify-maven-plugin-minify-maven-plugin-1.7.4/src/site/apt/examples/exclude.apt000066400000000000000000000036011237675341000276130ustar00rootroot00000000000000 ------ Exclude source files from WAR package ------ Samuel Santos ------ 2013-09-08 ------ Exclude source files from WAR package Sometimes we need to exclude the original source files from the final WAR package. A possible scenario is when you do not want to make them publicly available via your site for security reasons, or simply want to include only the minified (obfuscated) file resulting from the plugin execution. The example below illustrates how to configure Maven WAR Plugin to exclude the undesired source files from the final WAR package. +---+ org.apache.maven.plugins maven-war-plugin **/file-1.css,...,**/file-n.css,**/file-1.js,...,**/file-n.js com.samaxes.maven minify-maven-plugin 1.7.4 default-minify file-1.css file-n.css file-1.js file-n.js minify +---+ minify-maven-plugin-minify-maven-plugin-1.7.4/src/site/apt/examples/patterns.apt000066400000000000000000000025211237675341000300220ustar00rootroot00000000000000 ------ Using include/exclude patterns ------ Samuel Santos ------ 2013-09-08 ------ Using include/exclude patterns Since version 1.2, Minify Maven Plugin supports include/exclude patterns for lexicographical ordering. +---+ com.samaxes.maven minify-maven-plugin 1.7.4 default-minify ** **/*.min.css ** **/*.min.js minify +---+ minify-maven-plugin-minify-maven-plugin-1.7.4/src/site/apt/index.apt000066400000000000000000000037221237675341000254570ustar00rootroot00000000000000 ------ Introduction ------ Samuel Santos ------ 2013-09-08 ------ Minify Maven Plugin This plugin combines and minimizes your CSS and JavaScript files for faster page loading. It produces a merged and a minified version of your CSS and JavaScript resources which can be re-used across your project. Under the hood, it uses the {{{http://yui.github.com/yuicompressor/}YUI Compressor}} and {{{https://developers.google.com/closure/compiler/}Google Closure Compiler}} but has a layer of abstraction around these tools which allows for other tools to be added in the future. * Goals Overview * {{{./minify-mojo.html}minify:minify}} combine and minimize JavaScript and CSS files. * Usage General instructions on how to use the Minify Maven Plugin can be found on the {{{./usage.html}usage page}}. Some more specific use cases are described in the examples given below. If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our {{{./issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our {{{./source-repository.html}source repository}} and will find supplementary information in the {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. * Examples To provide you with better understanding of some usages of the Minify Maven Plugin, you can take a look into the following examples: * {{{./examples/basic.html}Basic Configuration}} * {{{./examples/patterns.html}Using include/exclude patterns}} * {{{./examples/exclude.html}Exclude source files from WAR package}} minify-maven-plugin-minify-maven-plugin-1.7.4/src/site/apt/usage.apt000066400000000000000000000066331237675341000254600ustar00rootroot00000000000000 ------ Usage ------ Samuel Santos ------ 2013-09-08 ------ Usage This document is intended to provide instructions for using the Minify Maven Plugin.\ In order for this discussion to be useful, it's critical to cover two topics: [[1]] Configuring your project's <<>> to run the plugin during the project's build cycle [[2]] Invoking the plugin from the command-line * Configure Minify Maven Plugin By tying the goals of the plugin to a phase in the build cycle, the specified goals will run each time that phase of the build cycle is executed. Doing this can make it easier to add the plugin to your project, because it eliminates the need to run the plugin standalone. To bind the minify goal of the Minify Maven Plugin to a phase in the build cycle, you will need to add the <<>> tag with the <<>> set to <<>>. Optionally, you can bind the plugin to a different build phase by using the <<>> option. For instance, using <<>> in the <<>> option will force the minify goal to run each time this phase of the build cycle occurs. For a complete list of the available configuration options see {{{./minify-mojo.html}minify:minify}} goal overview page. ** Merge order The following rules for file order are applied when input CSS files are merged and minified into a single output file: [[1]] Input files defined in <<>> are merged before files defined in <<>>. [[2]] Input files defined in <<>> are sorted by filename before merging (see {{{./examples/patterns.html}Using include/exclude patterns}}). [[3]] If a file is configured both in <<>> and <<>> then only the one defined in <<>> will be processed. The same rules for JavaScript files are applied for tags <<>> and <<>> respectively. +---+ com.samaxes.maven minify-maven-plugin 1.7.4 default-minify package UTF-8 css file-1.css file-n.css style.css js file-1.js file-n.js script.js CLOSURE minify +---+ * Invoke from the command-line Create the project archive containing the new files. +---+ mvn package +---+ minify-maven-plugin-minify-maven-plugin-1.7.4/src/site/fml/000077500000000000000000000000001237675341000236305ustar00rootroot00000000000000minify-maven-plugin-minify-maven-plugin-1.7.4/src/site/fml/faq.fml000066400000000000000000000026441237675341000251050ustar00rootroot00000000000000 Is it possible to create multiple CSS & JavaScript bundles?

Yes! Use multiple <execution> tags with different final names.

Note that execution id's have to be unique among all executions of a single plugin within a POM.

Where can I find a complete list of the available options to configure Minify Maven Plugin?

See minify:minify goal overview page.

Which JavaScript compressor engines does Minify Maven Plugin support?

Minify Maven Plugin supports YUI Compressor and Google Closure Compiler.

Use the values YUI or CLOSURE with the option <jsEngine> to select the engine to use.

minify-maven-plugin-minify-maven-plugin-1.7.4/src/site/site.xml000066400000000000000000000024731237675341000245460ustar00rootroot00000000000000 ${reports} org.apache.maven.skins maven-fluido-skin 1.3.1 samaxes/minify-maven-plugin right black samaxes true