public final void provide(AsciidocTemplateI template, Path targetDir) throws Exception {

		final var location = template.getLocation();
		var locationLowCase = location.toLowerCase();

		boolean isGitRepository = false;
		try {
			Collection<Ref> refs = Git.lsRemoteRepository()
					.setRemote(location)
					.call();
			if (Objects.nonNull(refs) && !refs.isEmpty()) {
				isGitRepository = true;
			}
		} catch (Exception e) {

		}

		String fileName = FilenameUtils.getName(location);
		final Path[] filePath = {targetDir.resolve(fileName)};

		if(isGitRepository){
			if(Files.exists(filePath[0])){
				filePath[0] = getNewFolder(targetDir);
			}
			Files.createDirectories(filePath[0]);
			logger.info("Cloning template from {}", location);
			try (Git git = Git.cloneRepository()
					.setURI(locationLowCase)
					.setDirectory(filePath[0].toFile())
					.call();) {
			}
		} else if (locationLowCase.startsWith("http://") || locationLowCase.startsWith("https://")) {
			logger.debug("Downloading template from: {}", location);
			Path zipPath = download(filePath[0], new URI(location));
			if (locationLowCase.endsWith(".zip")) {
				Path newFolder = getNewFolder(targetDir);
				Files.createDirectories(newFolder);
				logger.debug("Extracting zip: {}", zipPath);
				new ZipFile(zipPath.toFile()).extractAll(newFolder.toString());
				squeezeFolder(newFolder);
				IOHelper.deleteIfExists(zipPath);
			}
		} else {
			Path locationPath = Paths.get(location);
			if (Files.exists(locationPath)) {
				logger.debug("Coping template from: {}", location);
				Path newFolder = getNewFolder(targetDir);
				Files.createDirectories(newFolder);
				IOHelper.copyDirectory(locationPath, newFolder);
			} else {
				logger.error("Template not exist in the provided path: {}", locationPath);
			}
		}

		logger.debug("Template provided: {}", location);
	}
Depending on the location of the template downloads it or copies the file. If
it is a zip-archive it should be extracted. During the process no existing
files should be overwritten.

@param targetDir
@throws Exception
src/main/java/com/kodedu/service/TemplateService.java