@Override public String call() throws IOException { try { return MavenEmbedderUtils.getMavenVersion(new File(home)).getVersion(); } catch (MavenEmbedderException e) { throw new RuntimeException(e); } } });
/** * @param mavenHome * @return the maven version * @throws MavenEmbedderException */ public static MavenInformation getMavenVersion(File mavenHome) throws MavenEmbedderException { ClassRealm realm = buildClassRealm( mavenHome, null, null ); if (debug) { debugMavenVersion(realm); } ClassLoader original = Thread.currentThread().getContextClassLoader(); InputStream inputStream = null; try { Thread.currentThread().setContextClassLoader( realm ); URL resource = realm.findResource( POM_PROPERTIES_PATH ); inputStream = resource.openStream(); Properties properties = new Properties(); properties.load( inputStream ); return new MavenInformation( properties.getProperty( "version" ) , resource.toExternalForm() ); } catch ( IOException e ) { throw new MavenEmbedderException( e.getMessage(), e ); } finally { IOUtil.close( inputStream ); Thread.currentThread().setContextClassLoader( original ); } }
String mavenVersion = mavenInformation.getVersion(); listener.getLogger().println("Found mavenVersion " + mavenVersion + " from file " + mavenInformation.getVersionResourcePath());
String mavenVersion = mavenInformation.getVersion(); LOGGER.fine(getFullDisplayName()+" is building with mavenVersion " + mavenVersion + " from file " + mavenInformation.getVersionResourcePath());
String mavenVersion = mavenInformation.getVersion(); LOGGER.fine(getFullDisplayName()+" is building with mavenVersion " + mavenVersion + " from file " + mavenInformation.getVersionResourcePath());
public static boolean isAtLeastMavenVersion(File mavenHome, String version) throws MavenEmbedderException { ComparableVersion found = new ComparableVersion( getMavenVersion( mavenHome ).getVersion() ); ComparableVersion testedOne = new ComparableVersion( version ); return found.compareTo( testedOne ) >= 0; }
String mavenVersion = mavenInformation.getVersion(); listener.getLogger().println("Found mavenVersion " + mavenVersion + " from file " + mavenInformation.getVersionResourcePath());