Skip to content

Instantly share code, notes, and snippets.

@Swind
Created October 2, 2012 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Swind/3820049 to your computer and use it in GitHub Desktop.
Save Swind/3820049 to your computer and use it in GitHub Desktop.
[Scala][Script] Create Add jar to Maven Repository Command
import java.io.File
object CreateRepositoryCommand {
val PATH = """PATH"""
val command = "mvn install:install-file " +
"-Dfile=%s " +
"-DgroupId=%s " +
"-DartifactId=%s " +
"-Dversion=%s " +
"-Dpackaging=jar " +
"-DgeneratePom=true"
def main(args: Array[String]) {
val jarFolder = new File(PATH)
jarFolder.listFiles.foreach{
file=>
println(command.format(file.getName,groupId(file),artifactId(file),version(file)))
}
}
//Example File Name : org.eclipse.core.jobs_3.5.200.v20120521-2346.jar
def version(file:File) = file.getName.split("_").last.replace(".jar", "")
def groupId(file:File) = file.getName.split("_").head.split("\\.").take(3).mkString(".")
def artifactId(file:File) = file.getName.split("_").head
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment