-
Notifications
You must be signed in to change notification settings - Fork 69
Description
All usages of downloadJar can be replaced with downloadJarFromURL. The old method downloadJar is way too adjusted to old monolithic templates and can be removed.
The old update command (download of monolithic template jars) will be removed anyway.
Lines 111 to 112 in 5c64a1e
| TemplatesJarUtil.downloadJar("com.devonfw.cobigen", "templates-devon4j", "3.0.0", false, templatesPath.toFile()); | |
| TemplatesJarUtil.downloadJar("com.devonfw.cobigen", "templates-devon4j", "3.0.0", true, templatesPath.toFile()); |
cobigen/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/util/TemplatesJarUtil.java
Lines 48 to 90 in 5c64a1e
| public static String downloadJar(String groupId, String artifactId, String version, boolean isDownloadSource, | |
| File templatesDirectory) { | |
| // By default the version should be latest | |
| if (StringUtils.isEmpty(version)) { | |
| version = "LATEST"; | |
| } | |
| String mavenUrl = "https://repository.sonatype.org/service/local/artifact/maven/" + "redirect?r=central-proxy&g=" | |
| + groupId + "&a=" + artifactId + "&v=" + version; | |
| if (isDownloadSource) { | |
| mavenUrl = mavenUrl + "&c=sources"; | |
| } | |
| String fileName = ""; | |
| Path jarFilePath = getJarFile(isDownloadSource, templatesDirectory.toPath()); | |
| try { | |
| if (jarFilePath == null || !Files.exists(jarFilePath) | |
| || isJarOutdated(jarFilePath.toFile(), mavenUrl, isDownloadSource, templatesDirectory)) { | |
| HttpURLConnection conn = initializeConnection(mavenUrl); | |
| try (InputStream inputStream = conn.getInputStream()) { | |
| fileName = conn.getURL().getFile().substring(conn.getURL().getFile().lastIndexOf("/") + 1); | |
| File file = new File(templatesDirectory.getPath() + File.separator + fileName); | |
| Path targetPath = file.toPath(); | |
| if (!file.exists()) { | |
| Files.copy(inputStream, targetPath, StandardCopyOption.REPLACE_EXISTING); | |
| } | |
| } | |
| conn.disconnect(); | |
| } else { | |
| fileName = jarFilePath.toFile().getPath() | |
| .substring(jarFilePath.toFile().getPath().lastIndexOf(File.separator) + 1); | |
| } | |
| } catch (IOException e) { | |
| throw new CobiGenRuntimeException("Could not download file from " + mavenUrl, e); | |
| } | |
| return fileName; | |
| } |
cobigen/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/util/TemplatesJarUtil.java
Lines 92 to 99 in 5c64a1e
| /** | |
| * Downloads a jar from a given URL to template set downloaded directory | |
| * | |
| * @param downloadURL URl to download from | |
| * @param templateSetDirectory directory where the template sets are located | |
| * @return fileName Name of the file downloaded | |
| */ | |
| public static String downloadJarFromURL(String downloadURL, Path templateSetDirectory) { |
Can be removed:
cobigen/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/util/TemplatesJarUtil.java
Line 140 in 5c64a1e
| public static String downloadLatestDevon4jTemplates(boolean isDownloadSource, File templatesDirectory) { |
Can be removed:
cobigen/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/util/TemplatesJarUtil.java
Line 153 in 5c64a1e
| public static void downloadTemplatesByMavenCoordinates(Path templatesDirectory, |