Guest User

Untitled

a guest
Jul 17th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. TemplateSet templateSet =
  2. getNexus().getRepositoryTemplates().getTemplates( P2ContentClass.class );
  3. TemplateSet templateSet1 = templateSet.getTemplates( P2ProxyRepository.class );
  4. RepositoryTemplate template = (RepositoryTemplate) templateSet1.pick();
  5. try
  6. {
  7. ConfigurableRepository configurableRepository = template.getConfigurableRepository();
  8. CRepository repo =
  9. ( (CRepositoryCoreConfiguration) configurableRepository.getCurrentCoreConfiguration() ).getConfiguration( true );
  10. repo.setId( uri2RepositoryId( artifactRepositoryURI ) );
  11. repo.setName( artifactRepository.getAttribute( "name" ) );
  12. repo.setProviderRole( Repository.class.getName() );
  13. repo.setProviderHint( P2ProxyRepository.ROLE_HINT );
  14.  
  15. repo.setRemoteStorage( new CRemoteStorage() );
  16. repo.getRemoteStorage().setProvider( CommonsHttpClientRemoteStorage.PROVIDER_STRING );
  17. repo.getRemoteStorage().setUrl( artifactRepositoryURI );
  18. template.create();
  19. }
  20. catch ( ConfigurationException e )
  21. {
  22. throw new StorageException( "Could not create p2 proxy repository for "
  23. + artifactRepositoryURI, e );
  24. }
Add Comment
Please, Sign In to add comment