diff options
author | Martin Stockhammer <martin.stockhammer@ars.de> | 2018-03-29 23:47:13 +0200 |
---|---|---|
committer | Martin Stockhammer <martin.stockhammer@ars.de> | 2018-03-29 23:47:13 +0200 |
commit | 9cd3c61340d8c62df6c88c82b4dfdce429eb947e (patch) | |
tree | 03c88d9b706e77ab63fb81e6bf0f49d543fa814c /archiva-modules/plugins | |
parent | f18aa86c68f475c5932d818446f6dec644be635b (diff) | |
download | archiva-9cd3c61340d8c62df6c88c82b4dfdce429eb947e.tar.gz archiva-9cd3c61340d8c62df6c88c82b4dfdce429eb947e.zip |
Adding packedIndexDir
Diffstat (limited to 'archiva-modules/plugins')
2 files changed, 34 insertions, 4 deletions
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRemoteRepository.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRemoteRepository.java index 55305ca09..15b212e8e 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRemoteRepository.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRemoteRepository.java @@ -108,5 +108,8 @@ public class MavenRemoteRepository extends AbstractRemoteRepository } } - + @Override + public String toString() { + return super.toString()+", remoteIndexFeature="+remoteIndexFeature.toString()+", indexCreationFeature="+indexCreationFeature.toString(); + } } diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java index f50d7259e..c779baa42 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java @@ -150,6 +150,9 @@ public class MavenRepositoryProvider implements RepositoryProvider { IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class).get(); indexCreationFeature.setSkipPackedIndexCreation(cfg.isSkipPackedIndexCreation()); indexCreationFeature.setIndexPath(getURIFromString(cfg.getIndexDir())); + indexCreationFeature.setPackedIndexPath(getURIFromString(cfg.getPackedIndexDir())); + /* -> Should be created by MavenIndexProvider + Path indexPath; if (indexCreationFeature.getIndexPath().getScheme() == null) { indexPath = Paths.get(indexCreationFeature.getIndexPath().getPath()); @@ -167,7 +170,7 @@ public class MavenRepositoryProvider implements RepositoryProvider { } catch (IOException e) { log.error("Could not create index directory {}", absoluteIndexPath); throw new RepositoryException("Could not create index directory " + absoluteIndexPath); - } + }*/ ArtifactCleanupFeature artifactCleanupFeature = repo.getFeature(ArtifactCleanupFeature.class).get(); @@ -237,10 +240,14 @@ public class MavenRepositoryProvider implements RepositoryProvider { } else { credentials.setPassword(new char[0]); } + IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class).get(); if (cfg.getIndexDir() != null) { - IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class).get(); indexCreationFeature.setIndexPath(getURIFromString(cfg.getIndexDir())); } + if (cfg.getPackedIndexDir() != null) { + indexCreationFeature.setPackedIndexPath(getURIFromString(cfg.getPackedIndexDir())); + } + log.debug("Updated remote instance {}", repo); } @Override @@ -272,6 +279,7 @@ public class MavenRepositoryProvider implements RepositoryProvider { IndexCreationFeature indexCreationFeature = remoteRepository.getFeature(IndexCreationFeature.class).get(); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); + cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); RemoteIndexFeature remoteIndexFeature = remoteRepository.getFeature(RemoteIndexFeature.class).get(); cfg.setRemoteIndexUrl(remoteIndexFeature.getIndexUri().toString()); @@ -305,6 +313,7 @@ public class MavenRepositoryProvider implements RepositoryProvider { cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded()); IndexCreationFeature indexCreationFeature = managedRepository.getFeature(IndexCreationFeature.class).get(); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); + cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); cfg.setSkipPackedIndexCreation(indexCreationFeature.isSkipPackedIndexCreation()); ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature(ArtifactCleanupFeature.class).get(); @@ -345,7 +354,7 @@ public class MavenRepositoryProvider implements RepositoryProvider { try { indexDir = Paths.get(new URI(repository.getIndexDir().startsWith("file://") ? repository.getIndexDir() : "file://" + repository.getIndexDir())); if (indexDir.isAbsolute()) { - Path newDir = Paths.get(new URI(stagingRepository.getLocation().startsWith("file://") ? stagingRepository.getLocation() : "file://" + stagingRepository.getLocation())).resolve(".index"); + Path newDir = indexDir.getParent().resolve(indexDir.getFileName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX); log.debug("Changing index directory {} -> {}", indexDir, newDir); stagingRepository.setIndexDir(newDir.toString()); } else { @@ -358,6 +367,24 @@ public class MavenRepositoryProvider implements RepositoryProvider { } // in case of absolute dir do not use the same } + if (StringUtils.isNotBlank(repository.getPackedIndexDir())) { + Path packedIndexDir = null; + try { + packedIndexDir = Paths.get(new URI(repository.getPackedIndexDir().startsWith("file://") ? repository.getPackedIndexDir() : "file://" + repository.getPackedIndexDir())); + if (packedIndexDir.isAbsolute()) { + Path newDir = packedIndexDir.getParent().resolve(packedIndexDir.getFileName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX); + log.debug("Changing index directory {} -> {}", packedIndexDir, newDir); + stagingRepository.setPackedIndexDir(newDir.toString()); + } else { + log.debug("Keeping index directory {}", repository.getPackedIndexDir()); + stagingRepository.setPackedIndexDir(repository.getPackedIndexDir()); + } + } catch (URISyntaxException e) { + log.error("Could not parse index path as uri {}", repository.getPackedIndexDir()); + stagingRepository.setPackedIndexDir(""); + } + // in case of absolute dir do not use the same + } stagingRepository.setRefreshCronExpression(repository.getRefreshCronExpression()); stagingRepository.setReleases(repository.isReleases()); stagingRepository.setRetentionCount(repository.getRetentionCount()); |