Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 409397

Summary: Client minification in Tycho build
Product: [ECD] Orion Reporter: John Arthorne <john.arthorne>
Component: RelengAssignee: Szymon Brandys <Szymon.Brandys>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jan.sievers, matthias.sohn, Szymon.Brandys
Version: 3.0   
Target Milestone: 3.0 RC2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 399023    

Description John Arthorne CLA 2013-05-29 10:25:00 EDT
Our PDE build performs minification of the client side JavaScript and CSS using r.js. We need to add this capability to our Tycho-based build.
Comment 1 Jan Sievers CLA 2013-05-29 10:40:09 EDT
https://github.com/mcheely/requirejs-maven-plugin

may be worth a try
Comment 2 Szymon Brandys CLA 2013-06-03 03:41:48 EDT
(In reply to comment #1)
> https://github.com/mcheely/requirejs-maven-plugin
> 
> may be worth a try

I already tried that, but probably I did something wrong and it did not work for me :(
Comment 3 Szymon Brandys CLA 2013-06-03 12:30:08 EDT
I made some progress using a mix of ant task and the requirejs plugin. I added 

<plugin>
 <artifactId>maven-antrun-plugin</artifactId>
 <executions>
  <execution>
   <phase>compile</phase>
   <configuration>
    <tasks>
     <copy todir="./optimization">
      <fileset dir="./bundles/org.eclipse.orion.client.core/web" includes="**" />
      <fileset dir="./bundles/org.eclipse.orion.client.ui/web" includes="**" />
      <fileset dir="./bundles/org.eclipse.orion.client.editor/web" includes="**" />
      <fileset dir="./bundles/org.eclipse.orion.client.git/web" includes="**" />
      <fileset dir="./bundles/org.eclipse.orion.client.users/web" includes="**" />
     </copy>
    </tasks>
   </configuration>
   <goals>
    <goal>run</goal>
   </goals>
  </execution>
 </executions>
</plugin>

then I used 

<plugin>
 <groupId>com.github.mcheely</groupId>
 <artifactId>requirejs-maven-plugin</artifactId>
 <version>2.0.0-SNAPSHOT</version>
 <executions>
  <execution>
   <phase>compile</phase>
   <goals>
    <goal>optimize</goal>
   </goals>
  </execution>
 </executions>
 <configuration>
  <configFile>
   ${basedir}/buildconfig.js
  </configFile>
  <skip>false</skip>
 </configuration>
</plugin>

My build config is:

({
    appDir: "./optimization",
    baseUrl: '.',
    dir: "./appdirectory-build",
    modules: [
        {
            name: "index"
        }
    ],
    optimizeCss: "standard",
    optimize: "uglify",

    paths: {
    	orion: 'orion',
    	requirejs: 'requirejs',
    	text: 'requirejs/text',
        i18n: 'requirejs/i18n',
        domReady: 'requirejs/domReady',
        gcli: 'gcli/gcli',
        util: 'gcli/util'
    }
})

I managed to uglify files, but did not manage to use closure optimizer yet. One more step left is to copy files back to proper locations
and then continue the Tycho build.

I am not sure if this is the right direction, but it may work. I hope it helps others looking at the issue.
Comment 4 Szymon Brandys CLA 2013-06-05 11:18:36 EDT
I decided to do something simple regarding minification. I run the same code as we have in the old Orion build as an Ant task from Maven. It is not enabled by default. To enable it you have to run build using:

mvn clean install -DrequirejsHome=...

where requirejsHome is the same folder as in the old build. The structure is as follows:

requirejsHome
|
|_dist
} }_r.js
|
|_lib
  |_closure
  { }_compiler.jar
  |
  {_rhino
    |_js.jar

We could include this folder into Orion client repo, unless there are some license restrictions.

Thoughts?
Comment 5 Szymon Brandys CLA 2013-06-07 08:16:40 EDT
(In reply to comment #4)
> I decided to do something simple regarding minification. I run the same code
> as we have in the old Orion build as an Ant task from Maven. It is not
> enabled by default. To enable it you have to run build using:
> 
> mvn clean install -DrequirejsHome=...

Released to master. I raised Bug 410174 to update Orion Hudson task.