@@ -8,7 +8,6 @@ import java.nio.file.Path
88import java .nio .file .Paths
99import java .nio .file .StandardCopyOption
1010
11- import scala .sys .process .ProcessLogger
1211import scala .util .Try
1312import scala .util .control .NonFatal
1413
@@ -281,20 +280,20 @@ class MavenConfigGenerationTest extends BaseConfigSuite {
281280 }
282281 }
283282
284- private def check (testProject : String , submodules : List [String ] = Nil )(
283+ private def check (testProject : String , submodules : List [String ] = Nil , extraContent : Map [ String , String ] = Map .empty )(
285284 checking : (Config .File , String , List [Config .File ]) => Unit
286285 ): Unit = {
287286 println(s " Checking $testProject" )
288- def nameFromDirectory (projectString : String ) =
289- Paths .get(projectString).getParent().getFileName().toString()
290287 val tempDir = Files .createTempDirectory(" mavenBloop" )
291288 val outFile = copyFromResource(tempDir, testProject)
289+ extraContent.foreach { case (relativePath, content) =>
290+ val p = tempDir.resolve(relativePath)
291+ Files .createDirectories(p.getParent)
292+ Files .write(p, content.getBytes(" UTF-8" ))
293+ }
292294 submodules.foreach(copyFromResource(tempDir, _))
293295 val wrapperJar = copyFromResource(tempDir, s " maven-wrapper.jar " )
294- val wrapperPropertiesFile = copyFromResource(tempDir, s " maven-wrapper.properties " )
295-
296- // val all = Files.list(tempDir).collect(Collectors.toList())
297- import sys .process ._
296+ copyFromResource(tempDir, s " maven-wrapper.properties " )
298297
299298 val javaHome = Paths .get(System .getProperty(" java.home" ))
300299 val javaArgs = List [String ](
@@ -360,8 +359,6 @@ class MavenConfigGenerationTest extends BaseConfigSuite {
360359
361360 private def exec (cmd : Seq [String ], cwd : File ): Try [String ] = {
362361 Try {
363- val lastError = new StringBuilder
364- val swallowStderr = ProcessLogger (_ => (), err => { lastError.append(err); () })
365362 val processBuilder = new ProcessBuilder ()
366363 val out = new StringBuilder ()
367364 processBuilder.directory(cwd)
@@ -380,4 +377,28 @@ class MavenConfigGenerationTest extends BaseConfigSuite {
380377 }
381378 }
382379
380+
381+
382+ @ Test
383+ def issue85 () = {
384+ check(
385+ " issue_85/pom.xml" ,
386+ extraContent = Map (
387+ " issue_85/LICENSE" -> " LICENSE CONTENT" ,
388+ " issue_85/NOTICE" -> " NOTICE CONTENT"
389+ )
390+ ) { (configFile, projectName, subprojects) =>
391+ assert(subprojects.isEmpty)
392+ val resources = configFile.project.resources.getOrElse(Nil )
393+ val license = resources.find(_.toString.endsWith(" LICENSE" ))
394+ val notice = resources.find(_.toString.endsWith(" NOTICE" ))
395+ assert(license.isDefined, " LICENSE file should be included in resources" )
396+ assert(notice.isDefined, " NOTICE file should be included in resources" )
397+
398+ val baseDirectory = configFile.project.directory.toAbsolutePath
399+ val hasBaseDir = resources.exists(_.toAbsolutePath == baseDirectory)
400+ assert(! hasBaseDir, s " Base directory $baseDirectory should NOT be in resources when includes are specified " )
401+ }
402+ }
403+
383404}
0 commit comments