@Test public void testFindLocalRepository() { RepositorySystem system = RepositoryUtility.newRepositorySystem(); RepositorySystemSession session = RepositoryUtility.newSession(system); File local = session.getLocalRepository().getBasedir(); Assert.assertTrue(local.exists()); Assert.assertTrue(local.canRead()); Assert.assertTrue(local.canWrite()); }
private static String findLocalRepository() { Path home = Paths.get(System.getProperty("user.home")); Path localRepo = home.resolve(".m2").resolve("repository"); if (Files.isDirectory(localRepo)) { return localRepo.toAbsolutePath().toString(); } else { return makeTemporaryLocalRepository(); } }
RepositoryUtility { private static String findLocalRepository() { Path home = Paths.get(System.getProperty("user.home")); Path localRepo = home.resolve(".m2").resolve("repository"); if (Files.isDirectory(localRepo)) { return localRepo.toAbsolutePath().toString(); } else { return makeTemporaryLocalRepository(); } } }
RepositoryUtility { private static String findLocalRepository() { Path home = Paths.get(System.getProperty("user.home")); Path localRepo = home.resolve(".m2").resolve("repository"); if (Files.isDirectory(localRepo)) { return localRepo.toAbsolutePath().toString(); } else { return makeTemporaryLocalRepository(); } } private  RepositoryUtility(); }
RepositoryUtility { private static String findLocalRepository() { Path home = Paths.get(System.getProperty("user.home")); Path localRepo = home.resolve(".m2").resolve("repository"); if (Files.isDirectory(localRepo)) { return localRepo.toAbsolutePath().toString(); } else { return makeTemporaryLocalRepository(); } } private  RepositoryUtility(); static RepositorySystem newRepositorySystem(); static DefaultRepositorySystemSession newSession(RepositorySystem system); static DefaultRepositorySystemSession newSessionForMaven(RepositorySystem system); static RemoteRepository mavenRepositoryFromUrl(String mavenRepositoryUrl); static ImmutableList<String> findVersions(
      RepositorySystem repositorySystem, String groupId, String artifactId); static String findLatestCoordinates(
      RepositorySystem repositorySystem, String groupId, String artifactId); }
RepositoryUtility { private static String findLocalRepository() { Path home = Paths.get(System.getProperty("user.home")); Path localRepo = home.resolve(".m2").resolve("repository"); if (Files.isDirectory(localRepo)) { return localRepo.toAbsolutePath().toString(); } else { return makeTemporaryLocalRepository(); } } private  RepositoryUtility(); static RepositorySystem newRepositorySystem(); static DefaultRepositorySystemSession newSession(RepositorySystem system); static DefaultRepositorySystemSession newSessionForMaven(RepositorySystem system); static RemoteRepository mavenRepositoryFromUrl(String mavenRepositoryUrl); static ImmutableList<String> findVersions(
      RepositorySystem repositorySystem, String groupId, String artifactId); static String findLatestCoordinates(
      RepositorySystem repositorySystem, String groupId, String artifactId); static final RemoteRepository CENTRAL; }