2014-03-03 100 views
1

這是我的任務。除了swager罐子之外,它應該從戰爭的lib中移除所有的東西。SBT:無法定義任務

packageCleanWar := { 
    val war: File = (packageWar in Compile).value 
    val tmpDir = target.value/"tmp" 
    val warPath = war.getAbsolutePath 
    val nf = (s: String) => s match { 
    case s if s.startsWith("WEB-INF/lib/swagger") => true 
    case s if s.startsWith("WEB-INF/lib/") => false 
    case _ => true 
    } 
    IO.unzip(war, tmpDir, NameFilter.fnToNameFilter(nf)) 
    IO.delete(war) 
    val newWar = new File(warPath) 
    IO.zip(Path.allSubpaths(tmpDir), newWar) 
    newWar 
} 

雖然試圖加載它,我收到以下

C:\work\project\server\build.sbt:55: error: not found: value packageCleanWar 
packageCleanWar := { 
^ 
[error] Type error in expression 

allthough我在提到here相同的風格定義它。我做錯了什麼?

回答

2

您需要聲明的任務,以及定義它:

lazy val packageCleanWar = taskKey[File]("packageCleanWar description") 

packageCleanWar := { 
    val war: File = (packageWar in Compile).value 
    val tmpDir = target.value/"tmp" 
    val warPath = war.getAbsolutePath 
    val nf = (s: String) => s match { 
    case s if s.startsWith("WEB-INF/lib/swagger") => true 
    case s if s.startsWith("WEB-INF/lib/") => false 
    case _ => true 
    } 
    IO.unzip(war, tmpDir, NameFilter.fnToNameFilter(nf)) 
    IO.delete(war) 
    val newWar = new File(warPath) 
    IO.zip(Path.allSubpaths(tmpDir), newWar) 
    newWar 
} 

這是Tasks