I have Alfresco Community 5.2 and a custom JS library to bundle together in a single amp file because I need to use that library inside share.
I tried to put it under shareamp\web\js\
, like in the picture, but I can't compile the project because of a YUICompressor minify error, probably the JS library is too recent and not compatible with YUICompressor.
The error is the following
[ERROR] Failed to execute goal net.alchim31.maven:yuicompressor-maven-plugin:1.5.1:compress (compress-js) on project MyProjectShare: Execution compress-js of goal net.alchim31.maven:yuicompressor-maven-plugin:1.5.1:compress failed: Compilation produced 3 syntax errors. -> [Help 1]
I also tried to put it under the META-INF\resources
folder but it doesn't work. I can compile the project and create the .amp file, but the library is not present inside the amp, like it has been ignored.
Obviously I can't change or remove the library, neither I can make it ES5 compatible with an external tool like babel.js.
Where is the correct place to put the JS library? Is it possible to disable yuicompressor also for prduction? (and it is correct?), Can I configure maven to put the library back in the amp in the <build>
section (and how if it is correct?)
Thanks to all.
PS. I also would like to know if this problem I'm facing is caused by a wrong approach to alfresco/share extension, and, if so, how should be the best practice.
I've been able to workaround the problem adding the resources during maven install, that is, amp creation.
I placed the JS library under WEB-INF
folder, as explained in the question, so basically alfresco ignores them at compile time and they will not get compressed/minified by YUICompressor. During validate phase of the maven install process, those files are being copied inside the correct js path.
All seems to work as espected.
I configured maven-resources-plugin, here is the code
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/amp/web/BNextScanShare/js/DynamicWebTWAIN/</outputDirectory>
<resources>
<resource>
<directory>/src/main/resources/META-INF/resources/DynamicWebTWAIN</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>