org.apache.maven.wagon.repository.Repository Java Examples
The following examples show how to use
org.apache.maven.wagon.repository.Repository.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractDeployMojo.java From opoopress with Apache License 2.0 | 6 votes |
private Repository createRepository(Map<String, String> repo) throws MojoExecutionException, MojoFailureException { String id = repo.get("id"); String url = repo.get("url"); if (id == null || url == null) { throw new MojoFailureException("Deploy configuration must contains 'id' and 'url': " + repo); } url = resolveRepositoryURL(id, url); Properties props = new Properties(); for (String key : repo.keySet()) { if ("id".equals(key) || "url".equals(key)) { continue; } props.setProperty(key, repo.get(key)); } Repository repository = new Repository(id, appendSlash(url)); if (!props.isEmpty()) { repository.setParameters(props); } return repository; }
Example #2
Source File: AbstractDeployMojo.java From opoopress with Apache License 2.0 | 6 votes |
@Override protected void executeInternal(SiteConfigImpl config, SiteImpl site) throws MojoExecutionException, MojoFailureException { File destination = site.getDestination(); getLog().info("Destination [" + destination + "]"); getLog().info("Site root [" + site.getRoot() + "]"); if (!destination.exists()) { throw new MojoFailureException("The site output folder does not exist, please run mvn op:build first"); } List<Map<String, String>> deployList = getDeployRepositoryList(config); //config.get("deploy"); if (deployList == null || deployList.isEmpty()) { throw new MojoFailureException("Deploy configuration not found in config.yml"); } for (Map<String, String> deployRepo : deployList) { Repository repository = createRepository(deployRepo); deploy(site, destination, repository); } }
Example #3
Source File: DefaultVersionsHelperTest.java From versions-maven-plugin with Apache License 2.0 | 6 votes |
private DefaultVersionsHelper createHelper( String rulesUri, ArtifactMetadataSource metadataSource ) throws MojoExecutionException { final DefaultWagonManager wagonManager = new DefaultWagonManager() { public Wagon getWagon( Repository repository ) throws UnsupportedProtocolException, WagonConfigurationException { return new FileWagon(); } }; DefaultVersionsHelper helper = new DefaultVersionsHelper( new DefaultArtifactFactory(), new DefaultArtifactResolver(), metadataSource, new ArrayList(), new ArrayList(), new DefaultArtifactRepository( "", "", new DefaultRepositoryLayout() ), wagonManager, new Settings(), "", rulesUri, mock( Log.class ), mock( MavenSession.class ), new DefaultPathTranslator()); return helper; }
Example #4
Source File: S3Utils.java From lambadaframework with MIT License | 5 votes |
static String getBaseDirectory(Repository repository) { StringBuilder sb = new StringBuilder(repository.getBasedir()).deleteCharAt(0); if ((sb.length() != 0) && (sb.charAt(sb.length() - 1) != '/')) { sb.append('/'); } return sb.toString(); }
Example #5
Source File: AbstractDeployMojo.java From opoopress with Apache License 2.0 | 5 votes |
public static ProxyInfo getProxyInfo(Repository repository, WagonManager wagonManager) { ProxyInfo proxyInfo = wagonManager.getProxy(repository.getProtocol()); if (proxyInfo == null) { return null; } String host = repository.getHost(); String nonProxyHostsAsString = proxyInfo.getNonProxyHosts(); for (String nonProxyHost : StringUtils.split(nonProxyHostsAsString, ",;|")) { if (org.apache.commons.lang.StringUtils.contains(nonProxyHost, "*")) { // Handle wildcard at the end, beginning or middle of the nonProxyHost final int pos = nonProxyHost.indexOf('*'); String nonProxyHostPrefix = nonProxyHost.substring(0, pos); String nonProxyHostSuffix = nonProxyHost.substring(pos + 1); // prefix* if (StringUtils.isNotEmpty(nonProxyHostPrefix) && host.startsWith(nonProxyHostPrefix) && StringUtils.isEmpty(nonProxyHostSuffix)) { return null; } // *suffix if (StringUtils.isEmpty(nonProxyHostPrefix) && StringUtils.isNotEmpty(nonProxyHostSuffix) && host.endsWith(nonProxyHostSuffix)) { return null; } // prefix*suffix if (StringUtils.isNotEmpty(nonProxyHostPrefix) && host.startsWith(nonProxyHostPrefix) && StringUtils.isNotEmpty(nonProxyHostSuffix) && host.endsWith(nonProxyHostSuffix)) { return null; } } else if (host.equals(nonProxyHost)) { return null; } } return proxyInfo; }
Example #6
Source File: AbstractDeployMojo.java From opoopress with Apache License 2.0 | 5 votes |
private static void chmod(final Wagon wagon, final Repository repository, final String chmodOptions, final String chmodMode) throws MojoExecutionException { try { if (wagon instanceof CommandExecutor) { CommandExecutor exec = (CommandExecutor) wagon; exec.executeCommand("chmod " + chmodOptions + " " + chmodMode + " " + repository.getBasedir()); } // else ? silently ignore, FileWagon is not a CommandExecutor! } catch (CommandExecutionException e) { throw new MojoExecutionException("Error uploading site", e); } }
Example #7
Source File: MockWagon.java From archiva with Apache License 2.0 | 5 votes |
@Override public void connect( Repository repository, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider ) throws ConnectionException, AuthenticationException { }
Example #8
Source File: DownloadArtifactsTest.java From archiva with Apache License 2.0 | 5 votes |
@Test public void downloadWithRemoteRedirect() throws Exception { RemoteRepository remoteRepository = getRemoteRepositoriesService().getRemoteRepository( "central" ); remoteRepository.setUrl( "http://localhost:" + redirectPort ); getRemoteRepositoriesService().updateRemoteRepository( remoteRepository ); RoleManagementService roleManagementService = getRoleManagementService( authorizationHeader ); if ( !roleManagementService.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal" ).isExists() ) { roleManagementService.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal" ); } getUserService( authorizationHeader ).createGuestUser(); roleManagementService.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, "guest" ); roleManagementService.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal", "guest" ); getUserService( authorizationHeader ).removeFromCache( "guest" ); Path file = Paths.get( "target/junit-4.9.jar" ); Files.deleteIfExists( file ); HttpWagon httpWagon = new HttpWagon(); httpWagon.connect( new Repository( "foo", "http://localhost:" + port ) ); httpWagon.get( "repository/internal/junit/junit/4.9/junit-4.9.jar", file.toFile() ); ZipFile zipFile = new ZipFile( file.toFile() ); List<String> entries = getZipEntriesNames( zipFile ); ZipEntry zipEntry = zipFile.getEntry( "org/junit/runners/JUnit4.class" ); assertNotNull( "cannot find zipEntry org/junit/runners/JUnit4.class, entries: " + entries + ", content is: " + FileUtils.readFileToString( file.toFile(), Charset.forName( "UTF-8") ), zipEntry ); zipFile.close(); file.toFile().deleteOnExit(); }
Example #9
Source File: WagonUtils.java From versions-maven-plugin with Apache License 2.0 | 5 votes |
/** * Convenience method to create a wagon. * * @param serverId The serverId to use if the wagonManager needs help. * @param url The url to create a wagon for. * @param wagonManager The wgaon manager to use. * @param settings The settings to use. * @param logger The logger to use. * @return The wagon to connect to the url. * @throws org.apache.maven.wagon.UnsupportedProtocolException if the protocol is not supported. * @throws org.apache.maven.artifact.manager.WagonConfigurationException if the wagon cannot be configured. * @throws org.apache.maven.wagon.ConnectionException If the connection cannot be established. * @throws org.apache.maven.wagon.authentication.AuthenticationException If the connection cannot be authenticated. */ public static Wagon createWagon( String serverId, String url, WagonManager wagonManager, Settings settings, Log logger ) throws UnsupportedProtocolException, WagonConfigurationException, ConnectionException, AuthenticationException { Repository repository = new Repository( serverId, url ); Wagon wagon = wagonManager.getWagon( repository ); if ( logger.isDebugEnabled() ) { Debug debug = new Debug(); wagon.addSessionListener( debug ); wagon.addTransferListener( debug ); } ProxyInfo proxyInfo = getProxyInfo( settings ); if ( proxyInfo != null ) { wagon.connect( repository, wagonManager.getAuthenticationInfo( repository.getId() ), proxyInfo ); } else { wagon.connect( repository, wagonManager.getAuthenticationInfo( repository.getId() ) ); } return wagon; }
Example #10
Source File: SimpleStorageServiceWagon.java From lambadaframework with MIT License | 5 votes |
@Override protected void connectToRepository(Repository repository, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider) throws AuthenticationException { if (this.amazonS3 == null) { ClientConfiguration clientConfiguration = S3Utils.getClientConfiguration(proxyInfoProvider); this.bucketName = S3Utils.getBucketName(repository); this.baseDirectory = S3Utils.getBaseDirectory(repository); this.amazonS3 = new AmazonS3Client(new DefaultAWSCredentialsProviderChain(), clientConfiguration); Region region = Region.fromLocationConstraint(this.amazonS3.getBucketLocation(this.bucketName)); this.amazonS3.setEndpoint(region.getEndpoint()); } }
Example #11
Source File: AbstractWagon.java From lambadaframework with MIT License | 5 votes |
@Override public final void connect(Repository source, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider) throws ConnectionException, AuthenticationException { this.repository = source; this.sessionListenerSupport.fireSessionOpening(); try { connectToRepository(source, authenticationInfo, proxyInfoProvider); this.sessionListenerSupport.fireSessionLoggedIn(); this.sessionListenerSupport.fireSessionOpened(); } catch (ConnectionException | AuthenticationException e) { this.sessionListenerSupport.fireSessionConnectionRefused(); throw e; } }
Example #12
Source File: WagonDelegate.java From archiva with Apache License 2.0 | 4 votes |
@Override public void connect( Repository source, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo ) throws ConnectionException, AuthenticationException { delegate.connect( source, authenticationInfo, proxyInfo ); }
Example #13
Source File: S3Utils.java From lambadaframework with MIT License | 4 votes |
static String getBucketName(Repository repository) { return repository.getHost(); }
Example #14
Source File: AbstractWagon.java From lambadaframework with MIT License | 4 votes |
@Override public final Repository getRepository() { return this.repository; }
Example #15
Source File: AbstractWagon.java From lambadaframework with MIT License | 4 votes |
@Override public final void connect(Repository source) throws ConnectionException, AuthenticationException { connect(source, null, (ProxyInfoProvider) null); }
Example #16
Source File: GitHubWagon.java From opoopress with Apache License 2.0 | 4 votes |
@Override public void putDirectory(File sourceDirectory, String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { String userName = getAuthenticationInfo().getUserName(); String password = getAuthenticationInfo().getPassword(); Repository repo = getRepository(); String[] strings = StringUtils.split(repo.getBasedir(), '/'); if(strings.length != 2){ throw new IllegalArgumentException("GitHub url error, no repository owner or name."); } String repositoryName = strings[1]; String repositoryOwner = strings[0]; String branch = repo.getParameter("branch"); String dryRun = repo.getParameter("dryRun"); String force = repo.getParameter("force"); String host = repo.getParameter("host"); String merge = repo.getParameter("merge"); String message = repo.getParameter("message"); String noJekyll = repo.getParameter("noJekyll"); String oauth2Token = repo.getParameter("oauth2Token"); String repoUsername = repo.getUsername(); String repoPassword = repo.getPassword(); String threads = System.getProperty("threads", "1"); if(StringUtils.isNotBlank(repoUsername)){ fireTransferDebug("Override userName: " + userName + " -> " + repoUsername); userName = repoUsername; } if(StringUtils.isNotBlank(repoPassword)){ fireTransferDebug("Override password by repository's."); password = repoPassword; } fireTransferDebug("userName: " + userName); fireTransferDebug("password: " + (password != null ? "***" : "")); fireTransferDebug("message: " + message); fireTransferDebug("branch: " + branch); fireTransferDebug("dryRun: " + dryRun); fireTransferDebug("force: " + force); fireTransferDebug("host: " + host); fireTransferDebug("merge: " + merge); fireTransferDebug("noJekyll: " + noJekyll); fireTransferDebug("oauth2Token: " + oauth2Token); fireTransferDebug("numThreads: " + threads); GitHub github = new GitHub(); github.setUserName(userName); github.setPassword(password); github.setRepositoryName(repositoryName); github.setRepositoryOwner(repositoryOwner); if(StringUtils.isNotBlank(branch)){ github.setBranch(branch); } if(StringUtils.isNotBlank(dryRun)){ github.setDryRun("true".equals(dryRun)); } // github.setExcludes(excludes); if(StringUtils.isNotBlank(force)){ github.setForce("force".equals(force)); } if(StringUtils.isNotBlank(host)){ github.setHost(host); } // github.setIncludes(includes); if(StringUtils.isNotBlank(merge)){ github.setMerge("true".equals(merge)); } if(StringUtils.isNotBlank(message)){ github.setMessage(message); } if(StringUtils.isNotBlank(noJekyll)){ github.setNoJekyll("true".equals(noJekyll)); } if(StringUtils.isNotBlank(oauth2Token)){ github.setOauth2Token(oauth2Token); } if(StringUtils.isNumeric(threads)){ github.setNumThreads(Integer.parseInt(threads)); } try { github.deploy(sourceDirectory, destinationDirectory); } catch (GitHubException e) { throw new TransferFailedException(e.getMessage(), e); } }
Example #17
Source File: GitWagon.java From opoopress with Apache License 2.0 | 4 votes |
public void putDirectory(File sourceDirectory, String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { if (!sourceDirectory.isDirectory()) { throw new IllegalArgumentException("Source is not a directory: " + sourceDirectory); } String resourceName = FilenameUtils.separatorsToUnix(destinationDirectory); Resource resource = new Resource(resourceName); firePutInitiated(resource, sourceDirectory); firePutStarted(resource, sourceDirectory); Repository repo = getRepository(); String url = repo.getUrl(); if (url.endsWith("/")){ url = url.substring(0, url.length() - 1); } String remote = url.substring(4); String branch = repo.getParameter("branch"); String message = repo.getParameter("message"); if(remote.startsWith("default://")){ remote = remote.substring(10); } if(branch == null){ branch = "master"; } try { Git git = new Git(checkoutDirectory, remote, branch); if(message != null){ git.setMessage(message); } if(safeCheckout){//not cache, clone every time git.cloneAll(); }else{ git.pullAll(); } FileUtils.copyDirectoryStructure(sourceDirectory, new File(checkoutDirectory, destinationDirectory)); git.pushAll(); } catch (Exception e) { fireTransferError(resource, e, TransferEvent.REQUEST_PUT); throw new TransferFailedException("Unable to put file", e); } firePutCompleted(resource, sourceDirectory); }
Example #18
Source File: AbstractWagon.java From lambadaframework with MIT License | 4 votes |
@Override public final void connect(Repository source, ProxyInfo proxyInfo) throws ConnectionException, AuthenticationException { connect(source, null, proxyInfo); }
Example #19
Source File: MockWagon.java From archiva with Apache License 2.0 | 4 votes |
@Override public void connect( Repository repository, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo ) throws ConnectionException, AuthenticationException { }
Example #20
Source File: MockWagon.java From archiva with Apache License 2.0 | 4 votes |
@Override public void connect( Repository repository, AuthenticationInfo authenticationInfo ) throws ConnectionException, AuthenticationException { }
Example #21
Source File: MockWagon.java From archiva with Apache License 2.0 | 4 votes |
@Override public void connect( Repository repository, ProxyInfoProvider proxyInfoProvider ) throws ConnectionException, AuthenticationException { }
Example #22
Source File: MockWagon.java From archiva with Apache License 2.0 | 4 votes |
@Override public void connect( Repository repository, ProxyInfo proxyInfo ) throws ConnectionException, AuthenticationException { }
Example #23
Source File: MockWagon.java From archiva with Apache License 2.0 | 4 votes |
@Override public void connect( Repository repository ) throws ConnectionException, AuthenticationException { }
Example #24
Source File: MockWagon.java From archiva with Apache License 2.0 | 4 votes |
@Override public Repository getRepository() { return null; }
Example #25
Source File: WagonDelegate.java From archiva with Apache License 2.0 | 4 votes |
@Override public void connect( Repository source, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider ) throws ConnectionException, AuthenticationException { delegate.connect( source, authenticationInfo, proxyInfoProvider ); }
Example #26
Source File: WagonDelegate.java From archiva with Apache License 2.0 | 4 votes |
@Override public void connect( Repository source, AuthenticationInfo authenticationInfo ) throws ConnectionException, AuthenticationException { delegate.connect( source, authenticationInfo ); }
Example #27
Source File: WagonDelegate.java From archiva with Apache License 2.0 | 4 votes |
@Override public void connect( Repository source, ProxyInfoProvider proxyInfoProvider ) throws ConnectionException, AuthenticationException { delegate.connect( source, proxyInfoProvider ); }
Example #28
Source File: WagonDelegate.java From archiva with Apache License 2.0 | 4 votes |
@Override public void connect( Repository source, ProxyInfo proxyInfo ) throws ConnectionException, AuthenticationException { delegate.connect( source, proxyInfo ); }
Example #29
Source File: WagonDelegate.java From archiva with Apache License 2.0 | 4 votes |
@Override public void connect( Repository source ) throws ConnectionException, AuthenticationException { delegate.connect( source ); }
Example #30
Source File: WagonDelegate.java From archiva with Apache License 2.0 | 4 votes |
@Override public Repository getRepository() { return delegate.getRepository(); }