mirror of
https://github.com/Alfresco/alfresco-sdk.git
synced 2025-10-08 14:51:55 +00:00
Changes done for handling reserved words.
This commit is contained in:
@@ -287,56 +287,191 @@
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.gmaven</groupId>
|
||||||
|
<artifactId>gmaven-plugin</artifactId>
|
||||||
|
<version>1.5</version> <!-- Use the latest version available -->
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>check-js-files-inside-assembly</id>
|
||||||
|
<phase>generate-resources</phase> <!-- Choose a suitable phase -->
|
||||||
|
<goals>
|
||||||
|
<goal>execute</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<source>
|
||||||
|
def dirPath = "${project.basedir}/src/main/assembly/web" // Replace with your directory path
|
||||||
|
def dirExists = new File(dirPath).isDirectory()
|
||||||
|
|
||||||
|
if (dirExists)
|
||||||
|
{
|
||||||
|
def jsFilesExist = checkForJsFiles(new File(dirPath))
|
||||||
|
|
||||||
|
if (jsFilesExist) {
|
||||||
|
// Execute the minify step here or set a property to control it.
|
||||||
|
// For example, you can set a property to true to indicate that minification is required.
|
||||||
|
project.properties['minifyRequiredInAssembly'] = 'false'
|
||||||
|
println "JavaScript files found. Minification is required."
|
||||||
|
} else {
|
||||||
|
project.properties['minifyRequiredInAssembly'] = 'true'
|
||||||
|
println "No JavaScript files found. Skipping minification."
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
project.properties['minifyRequiredInAssembly'] = 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
def checkForJsFiles(File directory) {
|
||||||
|
def jsFilesExist = false
|
||||||
|
directory.eachFileRecurse { file ->
|
||||||
|
if (file.name.endsWith('.js') && !matchesExclusionPatterns(file.path)) {
|
||||||
|
jsFilesExist = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsFilesExist
|
||||||
|
}
|
||||||
|
|
||||||
|
def matchesExclusionPatterns(filePath) {
|
||||||
|
def exclusionPatterns = [
|
||||||
|
'webscripts',
|
||||||
|
'site-webscripts',
|
||||||
|
'META-INF',
|
||||||
|
'.*/.lib/.js',
|
||||||
|
'.*/.css',
|
||||||
|
'.*/.min/js',
|
||||||
|
'.*/.min/.css'
|
||||||
|
]
|
||||||
|
return exclusionPatterns.any { pattern -> filePath =~ /.*\/$pattern\/.*/ }
|
||||||
|
}
|
||||||
|
</source>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>check-js-files-inside-resources</id>
|
||||||
|
<phase>generate-resources</phase> <!-- Choose a suitable phase -->
|
||||||
|
<goals>
|
||||||
|
<goal>execute</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<source>
|
||||||
|
def dirPath = "${project.basedir}/src/main/resources" // Replace with your directory path
|
||||||
|
def dirExists = new File(dirPath).isDirectory()
|
||||||
|
|
||||||
|
if (dirExists)
|
||||||
|
{
|
||||||
|
def jsFilesExist = checkForJsFiles(new File(dirPath))
|
||||||
|
|
||||||
|
if (jsFilesExist) {
|
||||||
|
// Execute the minify step here or set a property to control it.
|
||||||
|
// For example, you can set a property to true to indicate that minification is required.
|
||||||
|
project.properties['minifyRequiredInResources'] = 'false'
|
||||||
|
println "JavaScript files found. Minification is required."
|
||||||
|
} else {
|
||||||
|
project.properties['minifyRequiredInResources'] = 'true'
|
||||||
|
println "No JavaScript files found. Skipping minification."
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
project.properties['minifyRequiredInResources'] = 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
def checkForJsFiles(File directory) {
|
||||||
|
def jsFilesExist = false
|
||||||
|
directory.eachFileRecurse { file ->
|
||||||
|
if (file.name.endsWith('.js') && !matchesExclusionPatterns(file.path)) {
|
||||||
|
jsFilesExist = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsFilesExist
|
||||||
|
}
|
||||||
|
|
||||||
|
def matchesExclusionPatterns(filePath) {
|
||||||
|
def exclusionPatterns = [
|
||||||
|
'webscripts',
|
||||||
|
'META-INF',
|
||||||
|
'.*/.lib/.js',
|
||||||
|
'.*/.css',
|
||||||
|
'.*/.min/js',
|
||||||
|
'.*/.min/.css'
|
||||||
|
]
|
||||||
|
return exclusionPatterns.any { pattern -> filePath =~ /.*\/$pattern\/.*/ }
|
||||||
|
}
|
||||||
|
</source>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
<!-- Compress JavaScript files and store as *-min.js -->
|
<!-- Compress JavaScript files and store as *-min.js -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.alchim31.maven</groupId>
|
<groupId>com.github.blutorange</groupId>
|
||||||
<artifactId>yuicompressor-maven-plugin</artifactId>
|
<artifactId>closure-compiler-maven-plugin</artifactId>
|
||||||
<version>1.5.1</version>
|
<version>2.27.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<!-- Compress the JS files under the assembly folder -->
|
<!-- Compress the JS files under the assembly folder -->
|
||||||
<execution>
|
<execution>
|
||||||
<id>compress-assembly</id>
|
<id>compress-assembly</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>compress</goal>
|
<goal>minify</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<sourceDirectory>${project.basedir}/src/main/assembly/web</sourceDirectory>
|
<baseSourceDir>${project.basedir}/src/main/assembly</baseSourceDir>
|
||||||
<outputDirectory>${project.basedir}/src/main/assembly/web</outputDirectory>
|
<baseTargetDir>${project.basedir}/src/main/assembly</baseTargetDir>
|
||||||
|
<sourceDir>web</sourceDir>
|
||||||
|
<targetDir>web</targetDir>
|
||||||
|
<skipMerge>true</skipMerge>
|
||||||
|
<skip>${minifyRequiredInAssembly}</skip>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.js</include>
|
||||||
|
</includes>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/webscripts/**</exclude>
|
<exclude>**/webscripts/**</exclude>
|
||||||
<exclude>**/site-webscripts/**</exclude>
|
<exclude>**/site-webscripts/**</exclude>
|
||||||
<exclude>**/META-INF/**</exclude>
|
<exclude>**/META-INF/**</exclude>
|
||||||
<exclude>**/*.lib.js</exclude>
|
<exclude>**/*.lib.js</exclude>
|
||||||
<exclude>**/*.css</exclude>
|
<exclude>**/*.css</exclude>
|
||||||
<exclude>**/*-min.js</exclude>
|
<exclude>**/*.min.js</exclude>
|
||||||
<exclude>**/*-min.css</exclude>
|
<exclude>**/*.min.css</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<force>true</force>
|
<force>true</force>
|
||||||
<jswarn>false</jswarn>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<!-- Compress the JS files under the resources folder -->
|
<!-- Compress the JS files under the resources folder -->
|
||||||
<execution>
|
<execution>
|
||||||
<id>compress-resources</id>
|
<id>compress-resources</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>compress</goal>
|
<goal>minify</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<baseSourceDir>${project.basedir}/src/main</baseSourceDir>
|
||||||
|
<baseTargetDir>${project.basedir}/src/main</baseTargetDir>
|
||||||
|
<sourceDir>resources</sourceDir>
|
||||||
|
<targetDir>resources</targetDir>
|
||||||
|
<skipMerge>true</skipMerge>
|
||||||
|
<skip>${minifyRequiredInResources}</skip>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.js</include>
|
||||||
|
</includes>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/webscripts/**</exclude>
|
<exclude>**/webscripts/**</exclude>
|
||||||
<exclude>**/site-webscripts/**</exclude>
|
<exclude>**/site-webscripts/**</exclude>
|
||||||
<exclude>**/*.lib.js</exclude>
|
<exclude>**/*.lib.js</exclude>
|
||||||
<exclude>**/*.css</exclude>
|
<exclude>**/*.css</exclude>
|
||||||
<exclude>**/*-min.js</exclude>
|
<exclude>**/*.min.js</exclude>
|
||||||
<exclude>**/*-min.css</exclude>
|
<exclude>**/*.min.css</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<force>true</force>
|
<force>true</force>
|
||||||
<jswarn>false</jswarn>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
<!-- Hot reloading with JRebel -->
|
<!-- Hot reloading with JRebel -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.zeroturnaround</groupId>
|
<groupId>org.zeroturnaround</groupId>
|
||||||
|
@@ -355,56 +355,191 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.gmaven</groupId>
|
||||||
|
<artifactId>gmaven-plugin</artifactId>
|
||||||
|
<version>1.5</version> <!-- Use the latest version available -->
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>check-js-files-inside-assembly</id>
|
||||||
|
<phase>generate-resources</phase> <!-- Choose a suitable phase -->
|
||||||
|
<goals>
|
||||||
|
<goal>execute</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<source>
|
||||||
|
def dirPath = "${project.basedir}/src/main/assembly/web" // Replace with your directory path
|
||||||
|
def dirExists = new File(dirPath).isDirectory()
|
||||||
|
|
||||||
|
if (dirExists)
|
||||||
|
{
|
||||||
|
def jsFilesExist = checkForJsFiles(new File(dirPath))
|
||||||
|
|
||||||
|
if (jsFilesExist) {
|
||||||
|
// Execute the minify step here or set a property to control it.
|
||||||
|
// For example, you can set a property to true to indicate that minification is required.
|
||||||
|
project.properties['minifyRequiredInAssembly'] = 'false'
|
||||||
|
println "JavaScript files found. Minification is required."
|
||||||
|
} else {
|
||||||
|
project.properties['minifyRequiredInAssembly'] = 'true'
|
||||||
|
println "No JavaScript files found. Skipping minification."
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
project.properties['minifyRequiredInAssembly'] = 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
def checkForJsFiles(File directory) {
|
||||||
|
def jsFilesExist = false
|
||||||
|
directory.eachFileRecurse { file ->
|
||||||
|
if (file.name.endsWith('.js') && !matchesExclusionPatterns(file.path)) {
|
||||||
|
jsFilesExist = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsFilesExist
|
||||||
|
}
|
||||||
|
|
||||||
|
def matchesExclusionPatterns(filePath) {
|
||||||
|
def exclusionPatterns = [
|
||||||
|
'webscripts',
|
||||||
|
'site-webscripts',
|
||||||
|
'META-INF',
|
||||||
|
'.*/.lib/.js',
|
||||||
|
'.*/.css',
|
||||||
|
'.*/.min/js',
|
||||||
|
'.*/.min/.css'
|
||||||
|
]
|
||||||
|
return exclusionPatterns.any { pattern -> filePath =~ /.*\/$pattern\/.*/ }
|
||||||
|
}
|
||||||
|
</source>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>check-js-files-inside-resources</id>
|
||||||
|
<phase>generate-resources</phase> <!-- Choose a suitable phase -->
|
||||||
|
<goals>
|
||||||
|
<goal>execute</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<source>
|
||||||
|
def dirPath = "${project.basedir}/src/main/resources" // Replace with your directory path
|
||||||
|
def dirExists = new File(dirPath).isDirectory()
|
||||||
|
|
||||||
|
if (dirExists)
|
||||||
|
{
|
||||||
|
def jsFilesExist = checkForJsFiles(new File(dirPath))
|
||||||
|
|
||||||
|
if (jsFilesExist) {
|
||||||
|
// Execute the minify step here or set a property to control it.
|
||||||
|
// For example, you can set a property to true to indicate that minification is required.
|
||||||
|
project.properties['minifyRequiredInResources'] = 'false'
|
||||||
|
println "JavaScript files found. Minification is required."
|
||||||
|
} else {
|
||||||
|
project.properties['minifyRequiredInResources'] = 'true'
|
||||||
|
println "No JavaScript files found. Skipping minification."
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
project.properties['minifyRequiredInResources'] = 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
def checkForJsFiles(File directory) {
|
||||||
|
def jsFilesExist = false
|
||||||
|
directory.eachFileRecurse { file ->
|
||||||
|
if (file.name.endsWith('.js') && !matchesExclusionPatterns(file.path)) {
|
||||||
|
jsFilesExist = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsFilesExist
|
||||||
|
}
|
||||||
|
|
||||||
|
def matchesExclusionPatterns(filePath) {
|
||||||
|
def exclusionPatterns = [
|
||||||
|
'webscripts',
|
||||||
|
'META-INF',
|
||||||
|
'.*/.lib/.js',
|
||||||
|
'.*/.css',
|
||||||
|
'.*/.min/js',
|
||||||
|
'.*/.min/.css'
|
||||||
|
]
|
||||||
|
return exclusionPatterns.any { pattern -> filePath =~ /.*\/$pattern\/.*/ }
|
||||||
|
}
|
||||||
|
</source>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
<!-- Compress JavaScript files and store as *-min.js -->
|
<!-- Compress JavaScript files and store as *-min.js -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.alchim31.maven</groupId>
|
<groupId>com.github.blutorange</groupId>
|
||||||
<artifactId>yuicompressor-maven-plugin</artifactId>
|
<artifactId>closure-compiler-maven-plugin</artifactId>
|
||||||
<version>1.5.1</version>
|
<version>2.27.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<!-- Compress the JS files under the assembly folder -->
|
<!-- Compress the JS files under the assembly folder -->
|
||||||
<execution>
|
<execution>
|
||||||
<id>compress-assembly</id>
|
<id>compress-assembly</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>compress</goal>
|
<goal>minify</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<sourceDirectory>${project.basedir}/src/main/assembly/web</sourceDirectory>
|
<baseSourceDir>${project.basedir}/src/main/assembly</baseSourceDir>
|
||||||
<outputDirectory>${project.basedir}/src/main/assembly/web</outputDirectory>
|
<baseTargetDir>${project.basedir}/src/main/assembly</baseTargetDir>
|
||||||
|
<sourceDir>web</sourceDir>
|
||||||
|
<targetDir>web</targetDir>
|
||||||
|
<skipMerge>true</skipMerge>
|
||||||
|
<skip>${minifyRequiredInAssembly}</skip>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.js</include>
|
||||||
|
</includes>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/webscripts/**</exclude>
|
<exclude>**/webscripts/**</exclude>
|
||||||
<exclude>**/site-webscripts/**</exclude>
|
<exclude>**/site-webscripts/**</exclude>
|
||||||
<exclude>**/META-INF/**</exclude>
|
<exclude>**/META-INF/**</exclude>
|
||||||
<exclude>**/*.lib.js</exclude>
|
<exclude>**/*.lib.js</exclude>
|
||||||
<exclude>**/*.css</exclude>
|
<exclude>**/*.css</exclude>
|
||||||
<exclude>**/*-min.js</exclude>
|
<exclude>**/*.min.js</exclude>
|
||||||
<exclude>**/*-min.css</exclude>
|
<exclude>**/*.min.css</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<force>true</force>
|
<force>true</force>
|
||||||
<jswarn>false</jswarn>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<!-- Compress the JS files under the resources folder -->
|
<!-- Compress the JS files under the resources folder -->
|
||||||
<execution>
|
<execution>
|
||||||
<id>compress-resources</id>
|
<id>compress-resources</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>compress</goal>
|
<goal>minify</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<baseSourceDir>${project.basedir}/src/main</baseSourceDir>
|
||||||
|
<baseTargetDir>${project.basedir}/src/main</baseTargetDir>
|
||||||
|
<sourceDir>resources</sourceDir>
|
||||||
|
<targetDir>resources</targetDir>
|
||||||
|
<skipMerge>true</skipMerge>
|
||||||
|
<skip>${minifyRequiredInResources}</skip>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.js</include>
|
||||||
|
</includes>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/webscripts/**</exclude>
|
<exclude>**/webscripts/**</exclude>
|
||||||
<exclude>**/site-webscripts/**</exclude>
|
<exclude>**/site-webscripts/**</exclude>
|
||||||
<exclude>**/*.lib.js</exclude>
|
<exclude>**/*.lib.js</exclude>
|
||||||
<exclude>**/*.css</exclude>
|
<exclude>**/*.css</exclude>
|
||||||
<exclude>**/*-min.js</exclude>
|
<exclude>**/*.min.js</exclude>
|
||||||
<exclude>**/*-min.css</exclude>
|
<exclude>**/*.min.css</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<force>true</force>
|
<force>true</force>
|
||||||
<jswarn>false</jswarn>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
<!-- Hot reloading with JRebel -->
|
<!-- Hot reloading with JRebel -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.zeroturnaround</groupId>
|
<groupId>org.zeroturnaround</groupId>
|
||||||
|
@@ -221,56 +221,191 @@
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.gmaven</groupId>
|
||||||
|
<artifactId>gmaven-plugin</artifactId>
|
||||||
|
<version>1.5</version> <!-- Use the latest version available -->
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>check-js-files-inside-assembly</id>
|
||||||
|
<phase>generate-resources</phase> <!-- Choose a suitable phase -->
|
||||||
|
<goals>
|
||||||
|
<goal>execute</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<source>
|
||||||
|
def dirPath = "${project.basedir}/src/main/assembly/web" // Replace with your directory path
|
||||||
|
def dirExists = new File(dirPath).isDirectory()
|
||||||
|
|
||||||
|
if (dirExists)
|
||||||
|
{
|
||||||
|
def jsFilesExist = checkForJsFiles(new File(dirPath))
|
||||||
|
|
||||||
|
if (jsFilesExist) {
|
||||||
|
// Execute the minify step here or set a property to control it.
|
||||||
|
// For example, you can set a property to true to indicate that minification is required.
|
||||||
|
project.properties['minifyRequiredInAssembly'] = 'false'
|
||||||
|
println "JavaScript files found. Minification is required."
|
||||||
|
} else {
|
||||||
|
project.properties['minifyRequiredInAssembly'] = 'true'
|
||||||
|
println "No JavaScript files found. Skipping minification."
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
project.properties['minifyRequiredInAssembly'] = 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
def checkForJsFiles(File directory) {
|
||||||
|
def jsFilesExist = false
|
||||||
|
directory.eachFileRecurse { file ->
|
||||||
|
if (file.name.endsWith('.js') && !matchesExclusionPatterns(file.path)) {
|
||||||
|
jsFilesExist = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsFilesExist
|
||||||
|
}
|
||||||
|
|
||||||
|
def matchesExclusionPatterns(filePath) {
|
||||||
|
def exclusionPatterns = [
|
||||||
|
'webscripts',
|
||||||
|
'site-webscripts',
|
||||||
|
'META-INF',
|
||||||
|
'.*/.lib/.js',
|
||||||
|
'.*/.css',
|
||||||
|
'.*/.min/js',
|
||||||
|
'.*/.min/.css'
|
||||||
|
]
|
||||||
|
return exclusionPatterns.any { pattern -> filePath =~ /.*\/$pattern\/.*/ }
|
||||||
|
}
|
||||||
|
</source>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>check-js-files-inside-resources</id>
|
||||||
|
<phase>generate-resources</phase> <!-- Choose a suitable phase -->
|
||||||
|
<goals>
|
||||||
|
<goal>execute</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<source>
|
||||||
|
def dirPath = "${project.basedir}/src/main/resources" // Replace with your directory path
|
||||||
|
def dirExists = new File(dirPath).isDirectory()
|
||||||
|
|
||||||
|
if (dirExists)
|
||||||
|
{
|
||||||
|
def jsFilesExist = checkForJsFiles(new File(dirPath))
|
||||||
|
|
||||||
|
if (jsFilesExist) {
|
||||||
|
// Execute the minify step here or set a property to control it.
|
||||||
|
// For example, you can set a property to true to indicate that minification is required.
|
||||||
|
project.properties['minifyRequiredInResources'] = 'false'
|
||||||
|
println "JavaScript files found. Minification is required."
|
||||||
|
} else {
|
||||||
|
project.properties['minifyRequiredInResources'] = 'true'
|
||||||
|
println "No JavaScript files found. Skipping minification."
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
project.properties['minifyRequiredInResources'] = 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
def checkForJsFiles(File directory) {
|
||||||
|
def jsFilesExist = false
|
||||||
|
directory.eachFileRecurse { file ->
|
||||||
|
if (file.name.endsWith('.js') && !matchesExclusionPatterns(file.path)) {
|
||||||
|
jsFilesExist = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsFilesExist
|
||||||
|
}
|
||||||
|
|
||||||
|
def matchesExclusionPatterns(filePath) {
|
||||||
|
def exclusionPatterns = [
|
||||||
|
'webscripts',
|
||||||
|
'META-INF',
|
||||||
|
'.*/.lib/.js',
|
||||||
|
'.*/.css',
|
||||||
|
'.*/.min/js',
|
||||||
|
'.*/.min/.css'
|
||||||
|
]
|
||||||
|
return exclusionPatterns.any { pattern -> filePath =~ /.*\/$pattern\/.*/ }
|
||||||
|
}
|
||||||
|
</source>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
<!-- Compress JavaScript files and store as *-min.js -->
|
<!-- Compress JavaScript files and store as *-min.js -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.alchim31.maven</groupId>
|
<groupId>com.github.blutorange</groupId>
|
||||||
<artifactId>yuicompressor-maven-plugin</artifactId>
|
<artifactId>closure-compiler-maven-plugin</artifactId>
|
||||||
<version>1.5.1</version>
|
<version>2.27.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<!-- Compress the JS files under the assembly folder -->
|
<!-- Compress the JS files under the assembly folder -->
|
||||||
<execution>
|
<execution>
|
||||||
<id>compress-assembly</id>
|
<id>compress-assembly</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>compress</goal>
|
<goal>minify</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<sourceDirectory>${project.basedir}/src/main/assembly/web</sourceDirectory>
|
<baseSourceDir>${project.basedir}/src/main/assembly</baseSourceDir>
|
||||||
<outputDirectory>${project.basedir}/src/main/assembly/web</outputDirectory>
|
<baseTargetDir>${project.basedir}/src/main/assembly</baseTargetDir>
|
||||||
|
<sourceDir>web</sourceDir>
|
||||||
|
<targetDir>web</targetDir>
|
||||||
|
<skipMerge>true</skipMerge>
|
||||||
|
<skip>${minifyRequiredInAssembly}</skip>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.js</include>
|
||||||
|
</includes>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/webscripts/**</exclude>
|
<exclude>**/webscripts/**</exclude>
|
||||||
<exclude>**/site-webscripts/**</exclude>
|
<exclude>**/site-webscripts/**</exclude>
|
||||||
<exclude>**/META-INF/**</exclude>
|
<exclude>**/META-INF/**</exclude>
|
||||||
<exclude>**/*.lib.js</exclude>
|
<exclude>**/*.lib.js</exclude>
|
||||||
<exclude>**/*.css</exclude>
|
<exclude>**/*.css</exclude>
|
||||||
<exclude>**/*-min.js</exclude>
|
<exclude>**/*.min.js</exclude>
|
||||||
<exclude>**/*-min.css</exclude>
|
<exclude>**/*.min.css</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<force>true</force>
|
<force>true</force>
|
||||||
<jswarn>false</jswarn>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<!-- Compress the JS files under the resources folder -->
|
<!-- Compress the JS files under the resources folder -->
|
||||||
<execution>
|
<execution>
|
||||||
<id>compress-resources</id>
|
<id>compress-resources</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>compress</goal>
|
<goal>minify</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<baseSourceDir>${project.basedir}/src/main</baseSourceDir>
|
||||||
|
<baseTargetDir>${project.basedir}/src/main</baseTargetDir>
|
||||||
|
<sourceDir>resources</sourceDir>
|
||||||
|
<targetDir>resources</targetDir>
|
||||||
|
<skipMerge>true</skipMerge>
|
||||||
|
<skip>${minifyRequiredInResources}</skip>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.js</include>
|
||||||
|
</includes>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/webscripts/**</exclude>
|
<exclude>**/webscripts/**</exclude>
|
||||||
<exclude>**/site-webscripts/**</exclude>
|
<exclude>**/site-webscripts/**</exclude>
|
||||||
<exclude>**/*.lib.js</exclude>
|
<exclude>**/*.lib.js</exclude>
|
||||||
<exclude>**/*.css</exclude>
|
<exclude>**/*.css</exclude>
|
||||||
<exclude>**/*-min.js</exclude>
|
<exclude>**/*.min.js</exclude>
|
||||||
<exclude>**/*-min.css</exclude>
|
<exclude>**/*.min.css</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<force>true</force>
|
<force>true</force>
|
||||||
<jswarn>false</jswarn>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
Reference in New Issue
Block a user