@@ -92,15 +92,17 @@ object BootstrapUtility {
9292 }
9393
9494 /**
95- * Prepares the environemnt for deployment. Should be called after package and assembly task.
96- *
97- * @param logger the sbt logger
98- * @param scalaLibraryVersion the scala library major version
99- */
100- def prepareDeploymentTask (logger : ManagedLogger , scalaLibraryVersion : String ): Unit = {
101- // Assuming, before this: clean, bs, assembly bootstrapProject, package
95+ * Prepares the environemnt for deployment. Should be called after package and assembly task.
96+ *
97+ * @param logger the sbt logger
98+ * @param scalaLibraryVersion the scala library major version
99+ * @param dev whether sbt scripts and stuff for plugin developers should be included
100+ */
101+ def prepareDeploymentTask (logger : ManagedLogger , scalaLibraryVersion : String , dev : Boolean ): Unit = {
102+ // Assuming, before this: clean, bs, assembly bootstrapProject, package and if dev apiProject/packagedArtifacts
102103 // Assuming: Hardcoded "bin/" and "deploy/" folders
103104 // Assuming: A folder called "deployment-files" with all additional files (license, bat, etc.)
105+ // Assuming: A folder called "deployment-files-dev" with more additional files for plugin developers (only included if dev == true)
104106
105107 withTaskInfo(" PREPARE DEPLOYMENT" , logger) {
106108
@@ -136,10 +138,25 @@ object BootstrapUtility {
136138 if (! deploymentFiles.exists()) {
137139 logger warn " Unable to find deployment files."
138140 } else {
139- for (deploymentFile <- deploymentFiles.listFiles()) {
140- Files .copy(Paths .get(deploymentFile.getAbsolutePath),
141- Paths .get(s " deploy/ ${deploymentFile.getName}" ))
142- logger info s " Finished copying additional deployment file ' ${deploymentFile.getName}'. "
141+ sbt.IO .copyDirectory(deploymentFiles, new File (" deploy/" ))
142+ logger info s " Finished copying additional deployment files. "
143+ }
144+
145+ if (dev) {
146+ val devDeploymentFiles = new File (" deployment-files-dev/" )
147+ if (! devDeploymentFiles.exists()) {
148+ logger warn " Unable to find dev deployment files."
149+ } else {
150+ sbt.IO .copyDirectory(devDeploymentFiles, new File (" deploy/" ))
151+ logger info " Finished copying additional dev deployment files."
152+ }
153+
154+ val requiredBuildFiles = Set (" BuildUtility.scala" , " build.properties" , " Plugin.scala" , " PluginCreateWizard.scala" ,
155+ " PluginLanguage.scala" , " PluginMetadata.scala" , " SbtFile.scala" )
156+ for (filepath <- requiredBuildFiles) {
157+ val origFile = new File (s " project/ $filepath" )
158+ val deployFile = new File (s " deploy/project/ $filepath" )
159+ sbt.IO .copyFile(origFile, deployFile)
143160 }
144161 }
145162 }
@@ -155,8 +172,8 @@ object BootstrapUtility {
155172 if (file.isFile) {
156173 file.delete()
157174 } else {
158- createOrEmptyFolder(file.getAbsolutePath)
159- file.delete()
175+ createOrEmptyFolder(file.getAbsolutePath)
176+ file.delete()
160177 }
161178 }
162179 } else {
@@ -165,19 +182,15 @@ object BootstrapUtility {
165182 }
166183
167184 /**
168- * Copies ONE jar file from the source to all target directories. Useful for single packaged jar files .
185+ * Copies all jar files from the source to all target directories.
169186 */
170187 private def copyJars (sourceDirectory : String , targetDirectories : List [String ], logger : ManagedLogger ): Unit = {
171188 val candidates = new File (sourceDirectory)
172189 .listFiles().filter(f => f.isFile && f.getName.toLowerCase.endsWith(" .jar" ))
173- if (candidates.length != 1 ) {
174- logger warn s " Unable to identify jar file in $sourceDirectory"
175- } else {
176- for (targetDirectory <- targetDirectories) {
177- Files .copy(Paths .get(candidates.head.getAbsolutePath),
178- Paths .get(s " $targetDirectory/ ${candidates.head.getName}" ))
179- logger info s " Finished copying file ' ${candidates.head.getAbsolutePath}' to ' $targetDirectory'. "
180- }
190+ for (targetDirectory <- targetDirectories; file <- candidates) {
191+ Files .copy(Paths .get(file.getAbsolutePath),
192+ Paths .get(s " $targetDirectory/ ${file.getName}" ))
193+ logger info s " Finished copying file ' ${file.getAbsolutePath}' to ' $targetDirectory'. "
181194 }
182195 }
183196}
0 commit comments