<dependencies>
;compiled
- for the "combat" assembly of the project. Compilation level ADVANCED_OPTIMIZATIONS
;merged
- for pasting all source js files into one, virtually without compilation. WHITESPACE_ONLY
compilation WHITESPACE_ONLY
, PRETTY_PRINT
formatting;sources
- for debugging javascript files in a browser. Compilation takes place as in the compiled
profile, but source files will be included in html;sources-no-compile
- for debugging html / css files. Compilation does not occur, just source files are connected to html;jar
β to build a jar archive for distribution;mvn site
.sources
and sources-no-compile
profiles, they will work if python is installed on the system. This limitation is due to the execution of the depswriter.py
script, which forms the deps.js
file, which is necessary for the Closure Library to work. Read more about depswriter here . mvn -DarchetypeRepository=http://urmuzov.github.com/maven-repository/releases/ \ -DarchetypeGroupId=com.github.urmuzov \ -DarchetypeArtifactId=closure-package-maven-archetype \ -DarchetypeVersion=1.0.2 \ -DgroupId=my.test.group \ -DartifactId=test-artifact \ -Dversion=1.0.0-SNAPSHOT \ -Dpackage=my.test.pkg \ archetype:generate
com.github.urmuzov:closure-package-maven-archetype:1.0.2
this command you will tell maven to generate a project based on the com.github.urmuzov:closure-package-maven-archetype:1.0.2
archetype com.github.urmuzov:closure-package-maven-archetype:1.0.2
located in the repository urmuzov.github.com/maven-repository/releases
urmuzov.github.com/maven-repository/releases
with the group, the artifact and the version of your project will be my.test.group
, test-artifact
and 1.0.0-SNAPSHOT
respectively, the main package of your project is my.test.pkg
.//
) ~$ cd test-artifact/ ~/test-artifact$ tree . βββ pom.xml βββ src βββ main βββ python β βββ closure-library // python deps.js β ... βββ resources β βββ jquery-1.4.4.min.js β βββ my β βββ test β βββ pkg //, β βββ javascript // , js , externs β βββ desktop.entry.js // β βββ mobile.entry.js // β βββ sample // js β βββ sample.js // βββ webapp βββ index.html // html desktop.entry.js βββ META-INF βββ mobile.html // html mobile.entry.js βββ WEB-INF βββ web.xml βββ wro.xml // wro 14 directories, 19 files
compiled
you can use any of the 5 profiles. ~/test-artifact$ mvn -P compiled clean install [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building test-artifact 1.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ ... [INFO] --- closure-package-maven-plugin:1.0.2:copy (default) @ test-artifact --- [INFO] [INFO] --- closure-compiler-maven-plugin:1.0.2:compile (compile-advanced) @ test-artifact --- [INFO] simplePasses: [desktop, mobile] [INFO] == SimplePass (/home/urmuzov/test-artifact/target/closure/javascript/desktop.entry.js -> /home/urmuzov/test-artifact/target/test-artifact/desktop.js) == [INFO] file size: desktop.js -> 1588 bytes [INFO] == SimplePass (/home/urmuzov/test-artifact/target/closure/javascript/mobile.entry.js -> /home/urmuzov/test-artifact/target/test-artifact/mobile.js) == [INFO] file size: mobile.js -> 1587 bytes ... [INFO] --- gmaven-plugin:1.0-rc-5:execute (property-setup) @ test-artifact --- [INFO] SimplePass[desktop]: For simple inclusion use ${desktop.entry.js} in your HTML file [INFO] SimplePass[mobile]: For simple inclusion use ${mobile.entry.js} in your HTML file ... [INFO] --- wro4j-maven-plugin:1.3.8:run (default) @ test-artifact --- ... [INFO] /home/urmuzov/java/target/test-artifact/target/all.js (78601bytes) has been created! ... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
~/test-artifact$ cd target/test-artifact/ ~/test-artifact/target/test-artifact$ tree . βββ desktop.js // desktop.entry.js βββ index.html // html desktop.entry.js βββ META-INF // META-INF javasript βββ mobile.html // html mobile.entry.js βββ mobile.js // mobile.entry.js βββ target β βββ all.js // all src/main/webapp/WEB-INF/wro.xml βββ WEB-INF // WEB-INF javasript
closure-package-maven-plugin
looked at all <dependency>
project in search of closure-packages, found the packed Closure Library and unpacked it into a special directory for the compiler <dependency> <groupId>com.github.urmuzov</groupId> <artifactId>closure-library-package</artifactId> <version>${closureMaven.version}</version> </dependency>
closure-compiler-maven-plugin
based on the value of the <properties>...<passes>desktop mobile</passes>...</properties>
property performed two βsimple passesβ compilations for the desktop.entry.js
and mobile.entry.js
files mobile.entry.js
compiled them into desktop.js
and mobile.js
. More information about the aisles, settings and the plugin in general can be found on this page .gmaven-plugin
, properties were generated for quickly connecting js files from html files, in this case ${desktop.entry.js}
and ${mobile.entry.js}
. Immediately answer the question, "why do we need these properties at all?". The thing is that when using compiled
or merged
profiles, you need to include only one file with compiled code, for example like this: <script type="text/javascript" src="desktop.js"></script>
sources
or sources-no-compile
profiles, you need to include three files, like this: <script type="text/javascript" src="goog/base.js"></script> <script type="text/javascript" src="deps.js"></script> <script type="text/javascript" src="desktop.entry.js"></script>
${output.closure.js.prefix}desktop${output.closure.js.suffix}
, which is converted into the necessary code for different profiles. For more convenience with the help of gmaven-plugin
this construction is converted into ${desktop.entry.js}
, an example of the html file can be found hereSource: https://habr.com/ru/post/130419/
All Articles