@Test public void testNormalize() throws Exception { ModuleVersionIdentifier moduleVersionIdentifier = new DefaultModuleVersionIdentifier( "group", "name", "1.2"); ILogger logger = new StdLogger(StdLogger.Level.VERBOSE); assertEquals("app", DependencyManager.normalize(logger, moduleVersionIdentifier, "app")); assertEquals(".app", DependencyManager.normalize(logger, moduleVersionIdentifier, ".app")); assertEquals("app@", DependencyManager.normalize(logger, moduleVersionIdentifier, "app.")); assertEquals("app@", DependencyManager.normalize(logger, moduleVersionIdentifier, "app ")); assertEquals("app@@@", DependencyManager.normalize(logger, moduleVersionIdentifier, "app...")); assertEquals("app@@@", DependencyManager.normalize(logger, moduleVersionIdentifier, "app. .")); assertEquals("app@@@@", DependencyManager.normalize(logger, moduleVersionIdentifier, "app. . ")); assertEquals("a@", DependencyManager.normalize(logger, moduleVersionIdentifier, "a.")); assertEquals("a@", DependencyManager.normalize(logger, moduleVersionIdentifier, "a ")); assertEquals("a@@@", DependencyManager.normalize(logger, moduleVersionIdentifier, "a...")); assertEquals(".app@@", DependencyManager.normalize(logger, moduleVersionIdentifier, ".app%%")); assertEquals("app.txt", DependencyManager.normalize(logger, moduleVersionIdentifier, "app.txt")); assertEquals("app@@@txt", DependencyManager.normalize(logger, moduleVersionIdentifier, "app%*?txt")); assertEquals("", DependencyManager.normalize(logger, moduleVersionIdentifier, "")); assertEquals("a", DependencyManager.normalize(logger, moduleVersionIdentifier, "a")); assertEquals("1", DependencyManager.normalize(logger, moduleVersionIdentifier, "1")); assertNull(DependencyManager.normalize(logger, moduleVersionIdentifier, null)); assertEquals(".", DependencyManager.normalize(logger, moduleVersionIdentifier, ".")); assertEquals("..", DependencyManager.normalize(logger, moduleVersionIdentifier, "..")); assertEquals("...", DependencyManager.normalize(logger, moduleVersionIdentifier, "...")); }
static String normalize(ILogger logger, ModuleVersionIdentifier id, String path) { if (path == null || path.isEmpty()) { logger.info(String.format( "When unzipping library '%s:%s:%s, either group, name or version is empty", id.getGroup(), id.getName(), id.getVersion())); return path; } String normalizedPath = path.replaceAll("[%<>:\"/?*\\\\]", "@"); if (normalizedPath == null || normalizedPath.isEmpty()) { logger.info(String.format( "When unzipping library '%s:%s:%s, the normalized '%s' is empty", id.getGroup(), id.getName(), id.getVersion(), path)); return path; } try { int pathPointer = normalizedPath.length() - 1; String suffix = ""; while (pathPointer >= 0 && (normalizedPath.charAt(pathPointer) == '.' || normalizedPath.charAt(pathPointer) == ' ')) { pathPointer--; suffix += "@"; } if (pathPointer < 0) { throw new RuntimeException(String.format( "When unzipping library '%s:%s:%s, " + "the path '%s' cannot be transformed into a valid directory name", id.getGroup(), id.getName(), id.getVersion(), path)); } return normalizedPath.substring(0, pathPointer + 1) + suffix; } catch (Exception e) { logger.error(e, String.format( "When unzipping library '%s:%s:%s', " + "Path normalization failed for input %s", id.getGroup(), id.getName(), id.getVersion(), path)); return path; } }
DependencyManager { static String normalize(ILogger logger, ModuleVersionIdentifier id, String path) { if (path == null || path.isEmpty()) { logger.info(String.format( "When unzipping library '%s:%s:%s, either group, name or version is empty", id.getGroup(), id.getName(), id.getVersion())); return path; } String normalizedPath = path.replaceAll("[%<>:\"/?*\\\\]", "@"); if (normalizedPath == null || normalizedPath.isEmpty()) { logger.info(String.format( "When unzipping library '%s:%s:%s, the normalized '%s' is empty", id.getGroup(), id.getName(), id.getVersion(), path)); return path; } try { int pathPointer = normalizedPath.length() - 1; String suffix = ""; while (pathPointer >= 0 && (normalizedPath.charAt(pathPointer) == '.' || normalizedPath.charAt(pathPointer) == ' ')) { pathPointer--; suffix += "@"; } if (pathPointer < 0) { throw new RuntimeException(String.format( "When unzipping library '%s:%s:%s, " + "the path '%s' cannot be transformed into a valid directory name", id.getGroup(), id.getName(), id.getVersion(), path)); } return normalizedPath.substring(0, pathPointer + 1) + suffix; } catch (Exception e) { logger.error(e, String.format( "When unzipping library '%s:%s:%s', " + "Path normalization failed for input %s", id.getGroup(), id.getName(), id.getVersion(), path)); return path; } } }
DependencyManager { static String normalize(ILogger logger, ModuleVersionIdentifier id, String path) { if (path == null || path.isEmpty()) { logger.info(String.format( "When unzipping library '%s:%s:%s, either group, name or version is empty", id.getGroup(), id.getName(), id.getVersion())); return path; } String normalizedPath = path.replaceAll("[%<>:\"/?*\\\\]", "@"); if (normalizedPath == null || normalizedPath.isEmpty()) { logger.info(String.format( "When unzipping library '%s:%s:%s, the normalized '%s' is empty", id.getGroup(), id.getName(), id.getVersion(), path)); return path; } try { int pathPointer = normalizedPath.length() - 1; String suffix = ""; while (pathPointer >= 0 && (normalizedPath.charAt(pathPointer) == '.' || normalizedPath.charAt(pathPointer) == ' ')) { pathPointer--; suffix += "@"; } if (pathPointer < 0) { throw new RuntimeException(String.format( "When unzipping library '%s:%s:%s, " + "the path '%s' cannot be transformed into a valid directory name", id.getGroup(), id.getName(), id.getVersion(), path)); } return normalizedPath.substring(0, pathPointer + 1) + suffix; } catch (Exception e) { logger.error(e, String.format( "When unzipping library '%s:%s:%s', " + "Path normalization failed for input %s", id.getGroup(), id.getName(), id.getVersion(), path)); return path; } } DependencyManager(Project project, ExtraModelInfo extraModelInfo); }
DependencyManager { static String normalize(ILogger logger, ModuleVersionIdentifier id, String path) { if (path == null || path.isEmpty()) { logger.info(String.format( "When unzipping library '%s:%s:%s, either group, name or version is empty", id.getGroup(), id.getName(), id.getVersion())); return path; } String normalizedPath = path.replaceAll("[%<>:\"/?*\\\\]", "@"); if (normalizedPath == null || normalizedPath.isEmpty()) { logger.info(String.format( "When unzipping library '%s:%s:%s, the normalized '%s' is empty", id.getGroup(), id.getName(), id.getVersion(), path)); return path; } try { int pathPointer = normalizedPath.length() - 1; String suffix = ""; while (pathPointer >= 0 && (normalizedPath.charAt(pathPointer) == '.' || normalizedPath.charAt(pathPointer) == ' ')) { pathPointer--; suffix += "@"; } if (pathPointer < 0) { throw new RuntimeException(String.format( "When unzipping library '%s:%s:%s, " + "the path '%s' cannot be transformed into a valid directory name", id.getGroup(), id.getName(), id.getVersion(), path)); } return normalizedPath.substring(0, pathPointer + 1) + suffix; } catch (Exception e) { logger.error(e, String.format( "When unzipping library '%s:%s:%s', " + "Path normalization failed for input %s", id.getGroup(), id.getName(), id.getVersion(), path)); return path; } } DependencyManager(Project project, ExtraModelInfo extraModelInfo); static List<File> getPackagedLocalJarFileList(DependencyContainer dependencyContainer); void addDependencyToPrepareTask(
            @NonNull BaseVariantData<? extends BaseVariantOutputData> variantData,
            @NonNull PrepareDependenciesTask prepareDependenciesTask,
            @NonNull LibraryDependencyImpl lib); void resolveDependencies(
            @NonNull VariantDependencies variantDeps,
            @Nullable VariantDependencies testedVariantDeps,
            @Nullable String testedProjectPath); @NonNull static List<ManifestDependencyImpl> getManifestDependencies(
            List<LibraryDependency> libraries); }
DependencyManager { static String normalize(ILogger logger, ModuleVersionIdentifier id, String path) { if (path == null || path.isEmpty()) { logger.info(String.format( "When unzipping library '%s:%s:%s, either group, name or version is empty", id.getGroup(), id.getName(), id.getVersion())); return path; } String normalizedPath = path.replaceAll("[%<>:\"/?*\\\\]", "@"); if (normalizedPath == null || normalizedPath.isEmpty()) { logger.info(String.format( "When unzipping library '%s:%s:%s, the normalized '%s' is empty", id.getGroup(), id.getName(), id.getVersion(), path)); return path; } try { int pathPointer = normalizedPath.length() - 1; String suffix = ""; while (pathPointer >= 0 && (normalizedPath.charAt(pathPointer) == '.' || normalizedPath.charAt(pathPointer) == ' ')) { pathPointer--; suffix += "@"; } if (pathPointer < 0) { throw new RuntimeException(String.format( "When unzipping library '%s:%s:%s, " + "the path '%s' cannot be transformed into a valid directory name", id.getGroup(), id.getName(), id.getVersion(), path)); } return normalizedPath.substring(0, pathPointer + 1) + suffix; } catch (Exception e) { logger.error(e, String.format( "When unzipping library '%s:%s:%s', " + "Path normalization failed for input %s", id.getGroup(), id.getName(), id.getVersion(), path)); return path; } } DependencyManager(Project project, ExtraModelInfo extraModelInfo); static List<File> getPackagedLocalJarFileList(DependencyContainer dependencyContainer); void addDependencyToPrepareTask(
            @NonNull BaseVariantData<? extends BaseVariantOutputData> variantData,
            @NonNull PrepareDependenciesTask prepareDependenciesTask,
            @NonNull LibraryDependencyImpl lib); void resolveDependencies(
            @NonNull VariantDependencies variantDeps,
            @Nullable VariantDependencies testedVariantDeps,
            @Nullable String testedProjectPath); @NonNull static List<ManifestDependencyImpl> getManifestDependencies(
            List<LibraryDependency> libraries);  }