How to get programmatically the highest version for a Maven artifact from my local repository? -


in many posts saw aether project helps in working artifact repositories. retrieve highest version specified groupid , artifactid only.

in aether wiki present case org.apache.maven:maven-profile:2.2.1 artifact specify version:

dependency dependency =      new dependency(         new defaultartifact("org.apache.maven:maven-profile:2.2.1"),         "compile"     ); 

but need version, highest version artifact. how this?

if can read pom.xml file, can bare xml parsing.

public static string getversionof(file pomfile) throws parserconfigurationexception, ioexception, saxexception {     string version = "";      documentbuilderfactory dbfactory = documentbuilderfactory.newinstance();     documentbuilder dbuilder = dbfactory.newdocumentbuilder();     document doc = dbuilder.parse(pomfile);      nodelist nodelist = doc.getelementsbytagname("project");      for(int = 0; < nodelist.getlength(); i++) {         element node = (element) nodelist.item(i);          version = node.getelementsbytagname("version").item(0).gettextcontent();     }      return version; } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -