diff options
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/mill/main/Resolve.scala | 12 | ||||
-rw-r--r-- | core/src/mill/modules/Jvm.scala | 48 |
2 files changed, 33 insertions, 27 deletions
diff --git a/core/src/mill/main/Resolve.scala b/core/src/mill/main/Resolve.scala index ed4c4f80..3d9c0409 100644 --- a/core/src/mill/main/Resolve.scala +++ b/core/src/mill/main/Resolve.scala @@ -24,8 +24,12 @@ object Resolve { .map(Right(_)) def invokeCommand[V](target: mill.Module, name: String) = { - for(cmd <- discover.value.get(target.getClass).toSeq.flatten.find(_.name == name)) - yield cmd.asInstanceOf[EntryPoint[mill.Module]].invoke(target, ammonite.main.Scripts.groupArgs(rest.toList)) match { + + for{ + (cls, entryPoints) <- discover.value.filterKeys(_.isAssignableFrom(target.getClass)) + ep <- entryPoints + if ep.name == name + } yield ep.asInstanceOf[EntryPoint[mill.Module]].invoke(target, ammonite.main.Scripts.groupArgs(rest.toList)) match { case Router.Result.Success(v) => Right(v) case _ => Left(s"Command failed $last") } @@ -35,12 +39,12 @@ object Resolve { child <- obj.millInternal.reflectNestedObjects[mill.Module] if child.millOuterCtx.segment == Segment.Label(last) res <- child match{ - case taskMod: TaskModule => Some(invokeCommand(child, taskMod.defaultCommandName())) + case taskMod: TaskModule => Some(invokeCommand(child, taskMod.defaultCommandName()).headOption) case _ => None } } yield res - val command = invokeCommand(obj, last) + val command = invokeCommand(obj, last).headOption command orElse target orElse runDefault.headOption.flatten match{ case None => Left("Cannot resolve task " + diff --git a/core/src/mill/modules/Jvm.scala b/core/src/mill/modules/Jvm.scala index 888a687b..fdd928d7 100644 --- a/core/src/mill/modules/Jvm.scala +++ b/core/src/mill/modules/Jvm.scala @@ -162,33 +162,35 @@ object Jvm { (implicit ctx: Ctx.DestCtx): PathRef = { val outputPath = ctx.dest rm(outputPath) - if(inputPaths.nonEmpty) { - mkdir(outputPath/up) + mkdir(outputPath/up) - val jar = new JarOutputStream( - new FileOutputStream(outputPath.toIO), - createManifest(mainClass) - ) + val seen = mutable.Set.empty[RelPath] + seen.add("META-INF" / "MANIFEST.MF") + val jar = new JarOutputStream( + new FileOutputStream(outputPath.toIO), + createManifest(mainClass) + ) - try{ - assert(inputPaths.forall(exists(_))) - for{ - p <- inputPaths - (file, mapping) <- - if (p.isFile) Iterator(p -> empty/p.last) - else ls.rec(p).filter(_.isFile).map(sub => sub -> sub.relativeTo(p)) - } { - val entry = new JarEntry(mapping.toString) - entry.setTime(file.mtime.toMillis) - jar.putNextEntry(entry) - jar.write(read.bytes(file)) - jar.closeEntry() - } - } finally { - jar.close() + try{ + assert(inputPaths.forall(exists(_))) + for{ + p <- inputPaths + (file, mapping) <- + if (p.isFile) Iterator(p -> empty/p.last) + else ls.rec(p).filter(_.isFile).map(sub => sub -> sub.relativeTo(p)) + if !seen(mapping) + } { + seen.add(mapping) + val entry = new JarEntry(mapping.toString) + entry.setTime(file.mtime.toMillis) + jar.putNextEntry(entry) + jar.write(read.bytes(file)) + jar.closeEntry() } - + } finally { + jar.close() } + PathRef(outputPath) } |