@@ -83,25 +83,26 @@ subprojects {
83
83
84
84
if (project. solrSourceSetOverride != null ) {
85
85
doFirst {
86
- println (" The source code of the alfresco-search-*.jar will be overridden with code from (${ project.solrSourceSetOverride} )." )
86
+ println (" Note: the source code of the alfresco-search-*.jar will be overridden with code from (${ project.solrSourceSetOverride} )." )
87
87
}
88
- runCommand(' apt-get update -y && apt-get install zip -y' )
89
- // Fail if the alfresco-search-*.jar is not found.
90
- runCommand(' if [ -z $(ls /opt/alfresco-search-services/solr/server/solr-webapp/webapp/WEB-INF/lib/alfresco-search-*.jar) ]; then echo "Error: Alfresco Search jar not found"; exit 1; fi' )
91
- // Unzip the alfresco-search-*.jar to /tmp/alfresco-search, so we can override the classes.
92
- runCommand(' mkdir -p /tmp/alfresco-search' )
93
- runCommand(' cp /opt/alfresco-search-services/solr/server/solr-webapp/webapp/WEB-INF/lib/alfresco-search-*.jar /tmp/alfresco-search/temp.jar' )
94
- runCommand(' unzip -o /tmp/alfresco-search/temp.jar -d /tmp/alfresco-search' )
95
- runCommand(' rm -f /tmp/alfresco-search/temp.jar' )
96
- // Override the classes in the alfresco-search-*.jar with the classes from the project. Custom source sets can be provided.
88
+
89
+ // 1. Copy the classes from the sourceSet to a temp directory.
97
90
project. solrSourceSetOverride. classesDirs. each { classesDir ->
98
- smartCopy(classesDir, " /tmp/alfresco-search/" )
91
+ smartCopy(classesDir, " /tmp/alfresco-search-jar-source-override /" )
99
92
}
100
- // Cleanup & copy the temp.jar to the original location.
101
- // Do not clean up the /tmp/alfresco-search directory, as it can be used to double-check the actual classes in the jar.
102
- runCommand(' cd /tmp/alfresco-search && zip -r temp.jar *' )
103
- runCommand(' cp /tmp/alfresco-search/temp.jar $(ls /opt/alfresco-search-services/solr/server/solr-webapp/webapp/WEB-INF/lib/alfresco-search-*.jar)' )
104
- runCommand(' apt-get remove zip -y' )
93
+
94
+ // 2. Copy the classes from the temp directory to the alfresco-search-*.jar.
95
+ // Find the JAR.
96
+ runCommand(' alfresco_search_jar_location=$(ls /opt/alfresco-search-services/solr/server/solr-webapp/webapp/WEB-INF/lib/alfresco-search*.jar) && ' +
97
+ // Fail if the JAR is not found.
98
+ ' if [ -z "$alfresco_search_jar_location" ]; then echo "The alfresco-search-*.jar was not found."; exit 1; else echo "Found alfresco-search-*.jar at ($alfresco_search_jar_location)."; fi && ' +
99
+ // Copy the classes from the temp directory to the JAR.
100
+ ' cd /tmp/alfresco-search-jar-source-override && ' +
101
+ ' for file in $(find /tmp/alfresco-search-jar-source-override -name "*.class"); do ' +
102
+ ' echo "Copying ($file) to ($alfresco_search_jar_location)."; ' +
103
+ ' jar uf "$alfresco_search_jar_location" "${file##/tmp/alfresco-search-jar-source-override/}"; ' +
104
+ ' done' )
105
+ // Leave the adjusted classes in the temp directory. It gives a clear overview of the changes.
105
106
}
106
107
}
107
108
0 commit comments