0
maven 파일 이름을 artifact 및 버전으로 구문 분석하려면 어떻게해야합니까?구문 분석 Maven 파일 이름
파일 이름은 다음과 같이 :
test-file-12.2.2-SNAPSHOT.jar
test-lookup-1.0.16.jar
내가 그래서 artifactId를 대시 및 번호와 버전의 첫 번째 인스턴스 전에 텍스트가 텍스트가된다
test-file
12.2.2-SNAPSHOT
test-lookup
1.0.16
을 얻을 필요 최대 .jar까지의 숫자의 첫 번째 인스턴스 이후.
분할 및 여러 개의 루프 및 검사를 수행 할 수 있지만 더 간단한 방법이 있어야합니다.
편집 : 생각만큼
사실, 정규 표현식은 복잡하지 않았다!
new File("test").eachFile() { file ->
String fileName = file.name[0..file.name.lastIndexOf('.') - 1]
//Split at the first instance of a dash and a number
def split = fileName.split("-[\\d]")
String artifactId = split[0]
String version = fileName.substring(artifactId.length() + 1, fileName.length())
println(artifactId)
println(version)
}
EDIT2 : Hmm. 그것은 이와 같은 예에 실패
http://mvnrepository.com/artifact/org.xhtmlrenderer/core-renderer/R8
core-renderer-R8.jar
내가 할 필요가 무엇인지에 대해 생각 날 잡았어. 감사! – opticyclic