Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 Red Hat, Inc. and/or its affiliates.
   *
   * Licensed under the Eclipse Public License version 1.0, available at
   * http://www.eclipse.org/legal/epl-v10.html
   */
  package org.jboss.forge.maven;
  
 import  org.jboss.forge.parser.java.util.Strings;
Repository Utils

Author(s):
George Gastaldi <gegastaldi@gmail.com>
 
 public final class RepositoryUtils
 {
    private RepositoryUtils()
    {
    }
 
    {
       org.sonatype.aether.repository.Proxy result = null;
       if (proxy != null)
       {
          Authentication auth = new Authentication(proxy.getUsername(), proxy.getPassword());
          result = new org.sonatype.aether.repository.Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), auth);
       }
       return result;
    }
 
    {
       MavenArtifactRepository result = new MavenArtifactRepository();
       result.setId(repository.getId());
       result.setUrl(repository.getUrl());
 
       String layout = repository.getLayout();
       if ("default".equals(layout))
          result.setLayout(new DefaultRepositoryLayout());
       else if ("flat".equals(layout))
          result.setLayout(new FlatRepositoryLayout());
       else if ("p2".equals(layout))
          result.setLayout(new P2ArtifactRepositoryLayout());
 
       RepositoryPolicy releases = repository.getReleases();
       if (releases != null)
          result.setReleaseUpdatePolicy(new ArtifactRepositoryPolicy(releases.isEnabled(), releases.getUpdatePolicy(),
                   releases.getChecksumPolicy()));
 
       RepositoryPolicy snapshots = repository.getSnapshots();
       if (snapshots != null)
          result.setSnapshotUpdatePolicy(new ArtifactRepositoryPolicy(snapshots.isEnabled(),
                   snapshots.getUpdatePolicy(),
                   snapshots.getChecksumPolicy()));
 
       return result;
    }
 
    public static ArtifactRepository toArtifactRepository(String idString urlString layout,
             boolean containsReleases,
             boolean containsSnapshots)
    {
       MavenArtifactRepository result = new MavenArtifactRepository();
       result.setId(id);
       result.setUrl(url);
 
       if (Strings.isNullOrEmpty(layout) || "default".equals(layout))
       {
          result.setLayout(new DefaultRepositoryLayout());
       }
       else if ("flat".equals(layout))
       {
          result.setLayout(new FlatRepositoryLayout());
       }
       else if ("p2".equals(layout))
       {
          result.setLayout(new P2ArtifactRepositoryLayout());
       }
       result.setReleaseUpdatePolicy(new ArtifactRepositoryPolicy(containsReleases,
                .,
                .));
       result.setSnapshotUpdatePolicy(new ArtifactRepositoryPolicy(containsSnapshots,
                .,
                .));
       return result;
 
    }
 
New to GrepCode? Check out our FAQ X