Java 类org.apache.maven.model.Repository 实例源码

项目:xmvn    文件:DefaultModelProcessor.java   
private void visitPluginRepository( ModelVisitor visitor, Repository repository )
{
    RepositoryPolicy releases = repository.getReleases();
    if ( releases != null )
    {
        visitor.visitPluginRepositoryRelease( releases );
        releases = visitor.replacePluginRepositoryRelease( releases );
        repository.setReleases( releases );
    }

    RepositoryPolicy snapshots = repository.getSnapshots();
    if ( snapshots != null )
    {
        visitor.visitPluginRepositorySnapshot( snapshots );
        snapshots = visitor.replacePluginRepositorySnapshot( snapshots );
        repository.setSnapshots( snapshots );
    }
}
项目:xmvn    文件:DefaultModelProcessor.java   
private void visitProfilePluginRepository( ModelVisitor visitor, Repository repository )
{
    RepositoryPolicy releases = repository.getReleases();
    if ( releases != null )
    {
        visitor.visitProfilePluginRepositoryRelease( releases );
        releases = visitor.replaceProfilePluginRepositoryRelease( releases );
        repository.setReleases( releases );
    }

    RepositoryPolicy snapshots = repository.getSnapshots();
    if ( snapshots != null )
    {
        visitor.visitProfilePluginRepositorySnapshot( snapshots );
        snapshots = visitor.replaceProfilePluginRepositorySnapshot( snapshots );
        repository.setSnapshots( snapshots );
    }
}
项目:xmvn    文件:DefaultModelProcessor.java   
private void visitProfileRepository( ModelVisitor visitor, Repository repository )
{
    RepositoryPolicy releases = repository.getReleases();
    if ( releases != null )
    {
        visitor.visitProfileRepositoryRelease( releases );
        releases = visitor.replaceProfileRepositoryRelease( releases );
        repository.setReleases( releases );
    }

    RepositoryPolicy snapshots = repository.getSnapshots();
    if ( snapshots != null )
    {
        visitor.visitProfileRepositorySnapshot( snapshots );
        snapshots = visitor.replaceProfileRepositorySnapshot( snapshots );
        repository.setSnapshots( snapshots );
    }
}
项目:xmvn    文件:DefaultModelProcessor.java   
private void visitRepository( ModelVisitor visitor, Repository repository )
{
    RepositoryPolicy releases = repository.getReleases();
    if ( releases != null )
    {
        visitor.visitRepositoryRelease( releases );
        releases = visitor.replaceRepositoryRelease( releases );
        repository.setReleases( releases );
    }

    RepositoryPolicy snapshots = repository.getSnapshots();
    if ( snapshots != null )
    {
        visitor.visitRepositorySnapshot( snapshots );
        snapshots = visitor.replaceRepositorySnapshot( snapshots );
        repository.setSnapshots( snapshots );
    }
}
项目:release-candidate-maven-plugin    文件:Mojos.java   
public MavenProject mavenProjectFor(File pom, List<Property> properties) throws Exception {
    MavenXpp3Reader reader = new MavenXpp3Reader();
    Model model = reader.read(new FileReader(pom));

    for (Property p : properties) {
        model.addProperty(p.name, p.value);
    }

    model.setRepositories(new ArrayList<Repository>());

    MavenProject project = new MavenProject(model);

    project.setPluginArtifactRepositories(new ArrayList<ArtifactRepository>());
    project.setFile(pom);

    return project;
}
项目:flatten-maven-plugin    文件:FlattenMojo.java   
/**
 * Creates a flattened {@link List} of {@link Repository} elements where those from super-POM are omitted.
 *
 * @param repositories is the {@link List} of {@link Repository} elements. May be <code>null</code>.
 * @return the flattened {@link List} of {@link Repository} elements or <code>null</code> if <code>null</code> was
 *         given.
 */
protected static List<Repository> createFlattenedRepositories( List<Repository> repositories )
{
    if ( repositories != null )
    {
        List<Repository> flattenedRepositories = new ArrayList<Repository>( repositories.size() );
        for ( Repository repo : repositories )
        {
            // filter inherited repository section from super POM (see MOJO-2042)...
            if ( !isCentralRepositoryFromSuperPom( repo ) )
            {
                flattenedRepositories.add( repo );
            }
        }
        return flattenedRepositories;
    }
    return repositories;
}
项目:flatten-maven-plugin    文件:FlattenMojo.java   
/**
 * This method determines if the given {@link Repository} section is identical to what is defined from the super
 * POM.
 *
 * @param repo is the {@link Repository} section to check.
 * @return <code>true</code> if maven central default configuration, <code>false</code> otherwise.
 */
private static boolean isCentralRepositoryFromSuperPom( Repository repo )
{
    if ( repo != null )
    {
        if ( "central".equals( repo.getId() ) )
        {
            RepositoryPolicy snapshots = repo.getSnapshots();
            if ( snapshots != null && !snapshots.isEnabled() )
            {
                return true;
            }
        }
    }
    return false;
}
项目:che    文件:MavenModelUtil.java   
private static List<MavenRemoteRepository> convertRepositories(List<Repository> repositories) {
  List<MavenRemoteRepository> result = new ArrayList<>();
  if (repositories != null) {
    for (Repository repo : repositories) {
      result.add(
          new MavenRemoteRepository(
              repo.getId(),
              repo.getName(),
              repo.getUrl(),
              repo.getLayout(),
              convertPolicy(repo.getReleases()),
              convertPolicy(repo.getSnapshots())));
    }
  }

  return result;
}
项目:che    文件:MavenModelUtil.java   
public static Repository convertToMavenRepository(MavenRemoteRepository repository) {
  Repository result = new Repository();
  result.setId(repository.getId());
  result.setName(repository.getName());
  result.setUrl(repository.getUrl());
  if (repository.getLayout() == null) {
    result.setLayout("default");
  } else {
    result.setLayout(repository.getLayout());
  }
  if (repository.getSnapshotsPolicy() != null) {
    result.setSnapshots(convertToMavenPolicy(repository.getSnapshotsPolicy()));
  }

  if (repository.getReleasesPolicy() != null) {
    result.setReleases(convertToMavenPolicy(repository.getReleasesPolicy()));
  }
  return result;
}
项目:pom-manipulation-ext    文件:RepoAndReportingRemovalManipulator.java   
/**
 * Examine the repository to see if we should not remove it.
 * @param state to query the ignoreLocal value
 * @param repo the repository to examine
 * @return boolean whether to remove this repository
 */
private boolean removeRepository (RepoReportingState state, Repository repo)
{
    boolean result = true;

    if (state.ignoreLocal())
    {
        String url = repo.getUrl();
        // According to https://maven.apache.org/plugins/maven-site-plugin/examples/adding-deploy-protocol.html
        // supported repositories are file, http and https.
        if (url.startsWith( "file:" ) ||
            url.startsWith( "http://localhost" ) ||
            url.startsWith( "https://localhost" ) ||
            url.startsWith( "http://127.0.0.1" ) ||
            url.startsWith( "https://127.0.0.1" ) ||
            url.startsWith( "http://::1" ) ||
            url.startsWith( "https://::1" ) )
        {
            result = false;
        }
    }
    return result;
}
项目:pom-manipulation-ext    文件:RepositoryInjectionManipulator.java   
/**
 * Add the repository to the list of repositories. If an existing repository has the same
 * id it is removed first.
 *
 * @param repositories the current list of repositories
 * @param repository the repository to add
 */
private void addRepository( final List<Repository> repositories, final Repository repository )
{
    final Iterator<Repository> i = repositories.iterator();
    while ( i.hasNext() )
    {
        final Repository r = i.next();

        if ( repository.getId().equals( r.getId() ) )
        {
            logger.debug("Removing local repository {} ", r);
            i.remove();
            break;
        }
    }

    logger.debug( "Adding repository {}", repository );
    repositories.add(repository);
}
项目:furnace    文件:MavenModelResolver.java   
@Override
public void addRepository(final Repository repository, boolean replace) throws InvalidRepositoryException
{
   if (session.isIgnoreArtifactDescriptorRepositories())
   {
      return;
   }

   if (!repositoryIds.add(repository.getId()))
   {
      if (!replace)
      {
         return;
      }

      removeMatchingRepository(repository.getId());
   }
   repositories.add(new RemoteRepository.Builder(repository.getId(), repository.getName(), repository.getUrl())
            .build());
}
项目:oceano    文件:ProjectUtils.java   
public static ArtifactRepository buildArtifactRepository( Repository repo,
                                                          ArtifactRepositoryFactory artifactRepositoryFactory,
                                                          PlexusContainer c )
    throws InvalidRepositoryException
{
    RepositorySystem repositorySystem = rs( c );
    RepositorySystemSession session = rss( c );

    ArtifactRepository repository = repositorySystem.buildArtifactRepository( repo );

    if ( session != null )
    {
        repositorySystem.injectMirror( session, Arrays.asList( repository ) );
        repositorySystem.injectProxy( session, Arrays.asList( repository ) );
        repositorySystem.injectAuthentication( session, Arrays.asList( repository ) );
    }

    return repository;
}
项目:oceano    文件:ProfilesConversionUtils.java   
private static Repository convertFromProfileXmlRepository( org.apache.maven.profiles.Repository profileXmlRepo )
{
    Repository repo = new Repository();

    repo.setId( profileXmlRepo.getId() );
    repo.setLayout( profileXmlRepo.getLayout() );
    repo.setName( profileXmlRepo.getName() );
    repo.setUrl( profileXmlRepo.getUrl() );

    if ( profileXmlRepo.getSnapshots() != null )
    {
        repo.setSnapshots( convertRepositoryPolicy( profileXmlRepo.getSnapshots() ) );
    }
    if ( profileXmlRepo.getReleases() != null )
    {
        repo.setReleases( convertRepositoryPolicy( profileXmlRepo.getReleases() ) );
    }

    return repo;
}
项目:oceano    文件:LegacyRepositorySystemTest.java   
protected List<ArtifactRepository> getRemoteRepositories()
    throws Exception
{
    File repoDir = new File( getBasedir(), "src/test/remote-repo" ).getAbsoluteFile();

    RepositoryPolicy policy = new RepositoryPolicy();
    policy.setEnabled( true );
    policy.setChecksumPolicy( "ignore" );
    policy.setUpdatePolicy( "always" );

    Repository repository = new Repository();
    repository.setId( RepositorySystem.DEFAULT_REMOTE_REPO_ID );
    repository.setUrl( "file://" + repoDir.toURI().getPath() );
    repository.setReleases( policy );
    repository.setSnapshots( policy );

    return Arrays.asList( repositorySystem.buildArtifactRepository( repository ) );
}
项目:oceano    文件:ProjectModelResolver.java   
public void addRepository( Repository repository )
    throws InvalidRepositoryException
{
    if ( !repositoryIds.add( repository.getId() ) )
    {
        return;
    }

    List<RemoteRepository> newRepositories =
        Collections.singletonList( ArtifactDescriptorUtils.toRemoteRepository( repository ) );

    if ( ProjectBuildingRequest.RepositoryMerging.REQUEST_DOMINANT.equals( repositoryMerging ) )
    {
        repositories = remoteRepositoryManager.aggregateRepositories( session, repositories, newRepositories, true );
    }
    else
    {
        pomRepositories =
            remoteRepositoryManager.aggregateRepositories( session, pomRepositories, newRepositories, true );
        repositories =
            remoteRepositoryManager.aggregateRepositories( session, pomRepositories, externalRepositories, false );
    }
}
项目:oceano    文件:AbstractCoreMavenComponentTestCase.java   
protected List<ArtifactRepository> getRemoteRepositories()
    throws InvalidRepositoryException
{
    File repoDir = new File( getBasedir(), "src/test/remote-repo" ).getAbsoluteFile();

    RepositoryPolicy policy = new RepositoryPolicy();
    policy.setEnabled( true );
    policy.setChecksumPolicy( "ignore" );
    policy.setUpdatePolicy( "always" );

    Repository repository = new Repository();
    repository.setId( RepositorySystem.DEFAULT_REMOTE_REPO_ID );
    repository.setUrl( "file://" + repoDir.toURI().getPath() );
    repository.setReleases( policy );
    repository.setSnapshots( policy );

    return Arrays.asList( repositorySystem.buildArtifactRepository( repository ) );
}
项目:oceano    文件:DefaultModelValidator.java   
private void validate20EffectiveRepository( ModelProblemCollector problems, Repository repository, String prefix,
                                 ModelBuildingRequest request )
{
    if ( repository != null )
    {
        Severity errOn31 = getSeverity( request, ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 );

        validateBannedCharacters( prefix + ".id", problems, errOn31, Version.V20, repository.getId(), null, repository,
                                  ILLEGAL_REPO_ID_CHARS );

        if ( "local".equals( repository.getId() ) )
        {
            addViolation( problems, errOn31, Version.V20, prefix + ".id", null, "must not be 'local'"
                + ", this identifier is reserved for the local repository"
                + ", using it for other repositories will corrupt your repository metadata.", repository );
        }

        if ( "legacy".equals( repository.getLayout() ) )
        {
            addViolation( problems, Severity.WARNING, Version.V20, prefix + ".layout", repository.getId(),
                          "uses the unsupported value 'legacy', artifact resolution might fail.", repository );
        }
    }
}
项目:oceano    文件:DefaultModelBuilder.java   
private void configureResolver( ModelResolver modelResolver, Model model, DefaultModelProblemCollector problems )
{
    if ( modelResolver == null )
    {
        return;
    }

    problems.setSource( model );

    List<Repository> repositories = model.getRepositories();

    for ( Repository repository : repositories )
    {
        try
        {
            modelResolver.addRepository( repository );
        }
        catch ( InvalidRepositoryException e )
        {
            problems.add( new ModelProblemCollectorRequest(Severity.ERROR, Version.BASE)
                    .setMessage( "Invalid repository " + repository.getId() + ": " + e.getMessage())
                    .setLocation(repository.getLocation( "" ))
                    .setException(e) );
        }
    }
}
项目:oceano    文件:AbstractModelInterpolatorTest.java   
public void testBasedir()
    throws Exception
{
    Model model = new Model();
    model.setVersion( "3.8.1" );
    model.setArtifactId( "foo" );

    Repository repository = new Repository();

    repository.setUrl( "file://localhost/${basedir}/temp-repo" );

    model.addRepository( repository );

    ModelInterpolator interpolator = createInterpolator();

    final SimpleProblemCollector collector = new SimpleProblemCollector();
    Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector );
    assertProblemFree( collector );        

    assertEquals( "file://localhost/myBasedir/temp-repo", ( out.getRepositories().get( 0 ) ).getUrl() );
}
项目:oceano    文件:AbstractModelInterpolatorTest.java   
public void testBaseUri()
    throws Exception
{
    Model model = new Model();
    model.setVersion( "3.8.1" );
    model.setArtifactId( "foo" );

    Repository repository = new Repository();

    repository.setUrl( "${project.baseUri}/temp-repo" );

    model.addRepository( repository );

    ModelInterpolator interpolator = createInterpolator();

    final SimpleProblemCollector collector = new SimpleProblemCollector();
    Model out = interpolator.interpolateModel( model, null, createModelBuildingRequest( context ), collector );
    assertProblemFree( collector );

    assertEquals( "myBaseUri/temp-repo", ( out.getRepositories().get( 0 ) ).getUrl() );
}
项目:redhat-repository-validator    文件:BestPracticesValidator.java   
private void validateRepositories(ValidatorContext ctx, Model rawModel, Model effectiveModel) {
    if (!isEmpty(rawModel.getRepositories())) {
        if (allowedRepositoriesUrl != null) {
            for (Repository r : effectiveModel.getRepositories()) {
                if (r.getId() != null && r.getId().equals("central")) {
                    continue;
                }
                if (ArrayUtils.contains(allowedRepositoriesUrl, r.getUrl())) {
                    continue;
                }
                error(ctx, effectiveModel, "contains <repository> configuration with unallowed url " + r.getUrl());
            }
        }
        else {
            error(ctx, effectiveModel, "contains <repositories> configuration");
        }
    }
}
项目:redhat-repository-validator    文件:BestPracticesValidator.java   
private void validatePluginRepositories(ValidatorContext ctx, Model rawModel, Model effectiveModel) {
    if (!isEmpty(rawModel.getPluginRepositories())) {
        if( allowedPluginRepositoriesUrl != null ) {
            for( Repository r : effectiveModel.getPluginRepositories()) {
                if (r.getId() != null && r.getId().equals("central")) {
                    continue;
                }
                if (ArrayUtils.contains(allowedPluginRepositoriesUrl, r.getUrl())) {
                    continue;
                }
                error(ctx, effectiveModel, "contains <pluginRepository> configuration with unallowed url " + r.getUrl());
            }
        }
        else {
            error(ctx, effectiveModel, "contains <pluginRepositories> configuration");
        }
    }
}
项目:redhat-repository-validator    文件:TestBestPracticesValidator.java   
@Test
public void shouldFindBestPracticesViolation() {
    Repository repository = new Repository();
    repository.setId("repo-id");
    repository.setName("repo-name");
    repository.setUrl("repo-url");

    PomBuilder pomBuilder = pom();
    pomBuilder.model().addRepository(repository);
    pomBuilder.model().addPluginRepository(repository);
    pomBuilder.create(repoFooDir);

    validationExecutor.execute(ctx);
    assertExpectedException(BestPracticesException.class, "contains <repositories> configuration");
    assertExpectedException(BestPracticesException.class, "contains <pluginRepositories> configuration");
    assertExpectedException(BestPracticesException.class, "doesn't contain <name>");
    assertExpectedException(BestPracticesException.class, "doesn't contain <description>");
    assertExpectedException(BestPracticesException.class, "doesn't contain <url>");
    assertExpectedException(BestPracticesException.class, "doesn't contain <licenses>");
    assertExpectedException(BestPracticesException.class, "doesn't contain <developers>");
    assertExpectedException(BestPracticesException.class, "doesn't contain <scm>");
}
项目:incubator-netbeans    文件:LocationAwareMavenXpp3Writer.java   
private void writeRepository(Repository repository, String tagName, XmlSerializer serializer)
        throws java.io.IOException {
    serializer.startTag(NAMESPACE, tagName);
    flush(serializer);
    StringBuffer b = b(serializer);
    int start = b.length();
    if (repository.getReleases() != null) {
        writeRepositoryPolicy((RepositoryPolicy) repository.getReleases(), "releases", serializer);
    }
    if (repository.getSnapshots() != null) {
        writeRepositoryPolicy((RepositoryPolicy) repository.getSnapshots(), "snapshots", serializer);
    }
    if (repository.getId() != null) {
        writeValue(serializer, "id", repository.getId(), repository);
    }
    if (repository.getName() != null) {
        writeValue(serializer, "name", repository.getName(), repository);
    }
    if (repository.getUrl() != null) {
        writeValue(serializer, "url", repository.getUrl(), repository);
    }
    if ((repository.getLayout() != null) && !repository.getLayout().equals("default")) {
        writeValue(serializer, "layout", repository.getLayout(), repository);
    }
    serializer.endTag(NAMESPACE, tagName).flush();
    logLocation(repository, "", start, b.length());
}
项目:incubator-netbeans    文件:NBRepositoryModelResolver.java   
@Override
public void addRepository(Repository repository, boolean replace) throws InvalidRepositoryException {
    RepositorySystem repositorySystem = embedder.lookupComponent(RepositorySystem.class);
    try {
        ArtifactRepository repo = repositorySystem.buildArtifactRepository(repository);
        if(replace) { 
            remoteRepositories.remove(repo);
        }
        remoteRepositories.add(repo);
        remoteRepositories = repositorySystem.getEffectiveRepositories( remoteRepositories );
    } catch (org.apache.maven.artifact.InvalidRepositoryException ex) {
        throw new InvalidRepositoryException(ex.toString(), repository, ex);
    }
}
项目:migration-tooling    文件:DefaultModelResolver.java   
private DefaultModelResolver(
    Aether aether,
    Set<Repository> repositories,
    Map<String, ModelSource> ruleNameToModelSource,
    DefaultModelBuilder modelBuilder) {
  this.repositories = repositories;
  this.ruleNameToModelSource = ruleNameToModelSource;
  this.modelBuilder = modelBuilder;
  this.aether = aether;
  this.versionResolver = new VersionResolver(aether);
}
项目:migration-tooling    文件:DefaultModelResolver.java   
@Override
public ModelSource resolveModel(String groupId, String artifactId, String version)
    throws UnresolvableModelException {
  String ruleName = Rule.name(groupId, artifactId);
  if (ruleNameToModelSource.containsKey(ruleName)) {
    return ruleNameToModelSource.get(ruleName);
  }
  for (Repository repository : repositories) {
    UrlModelSource modelSource =
        getModelSource(repository.getUrl(), groupId, artifactId, version);
    if (modelSource != null) {
      return modelSource;
    }
  }

  List<String> attemptedUrls = repositories.stream().map(Repository::getUrl).collect(toList());
  throw new UnresolvableModelException(
      "Could not find any repositories that knew how to "
          + "resolve "
          + groupId
          + ":"
          + artifactId
          + ":"
          + version
          + " (checked "
          + Joiner.on(", ").join(attemptedUrls)
          + ")",
      groupId,
      artifactId,
      version);
}
项目:migration-tooling    文件:DefaultModelResolver.java   
/** Adds a user-specified repository to the list. */
public void addUserRepository(String url) {
  Repository repository = new Repository();
  repository.setUrl(url);
  repository.setId("user-defined repository");
  repository.setName("default");
  addRepository(repository);
  this.aether.addRemoteRepository(
      new RemoteRepository.Builder("user-defined repository", "default", url).build());
}
项目:apache-maven-shade-plugin    文件:MavenJDOMWriter.java   
/**
 * Method updateRepository
 *
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
protected void updateRepository( Repository value, String xmlTag, Counter counter, Element element )
{
    Element root = element;
    Counter innerCount = new Counter( counter.getDepth() + 1 );
    updateRepositoryPolicy( value.getReleases(), "releases", innerCount, root );
    updateRepositoryPolicy( value.getSnapshots(), "snapshots", innerCount, root );
    findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null );
    findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
    findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
    findAndReplaceSimpleElement( innerCount, root, "layout", value.getLayout(), "default" );
}
项目:apache-archiva    文件:RepositoryModelResolver.java   
@Override
public void addRepository( Repository repository )
    throws InvalidRepositoryException
{
    // we just ignore repositories outside of the current one for now
    // TODO: it'd be nice to look them up from Archiva's set, but we want to do that by URL / mapping, not just the
    //       ID since they will rarely match
}
项目:rug-resolver    文件:ManifestPomWriter.java   
private void addRepositories(Manifest manifest, Model model) {
    // add repository section
    manifest.repositories().forEach(r -> {
        Repository repo = new Repository();
        repo.setId(r.id());
        repo.setName(r.id());
        repo.setUrl(r.url());
        repo.setLayout("default");
        model.addRepository(repo);
    });
}
项目:gitflow-helper-maven-plugin    文件:AbstractGitflowBasedRepositoryMojo.java   
/**
 * Builds an ArtifactRepository for targeting deployments
 * .
 *
 * @param altRepository
 * @return
 * @throws MojoExecutionException
 * @throws MojoFailureException
 */
protected ArtifactRepository getDeploymentRepository(final String altRepository) throws MojoExecutionException, MojoFailureException {
    Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher(altRepository);
    Repository candidate = null;
    if (!matcher.matches()) {
        for (int i = 0; i < project.getRepositories().size(); i++) {
            candidate = project.getRepositories().get(i);
            getLog().debug("Checking defined repository ID: " + candidate.getId().trim() + " against: " + altRepository.trim());
            if (candidate.getId().trim().equals(altRepository.trim())) {
                break;
            }
            candidate = null;
        }

        if (candidate == null) {
            throw new MojoFailureException(altRepository, "Invalid syntax for repository or repository id not resolved..",
                    "Invalid syntax for repository. Use \"id::layout::url::unique\" or only specify the \"id\".");
        }
    }

    if (getLog().isDebugEnabled()) {
        getLog().debug("Getting maven deployment repository (to target artifacts) for: " + altRepository);
    }

    if (candidate == null) {
        String id = matcher.group(1).trim();
        String layout = matcher.group(2).trim();
        String url = matcher.group(3).trim();
        boolean unique = Boolean.parseBoolean(matcher.group(4).trim());

        ArtifactRepositoryLayout repoLayout = getLayout(layout);

        return repositoryFactory.createDeploymentArtifactRepository(id, url, repoLayout, unique);
    } else {
        return repositoryFactory.createDeploymentArtifactRepository(candidate.getId(), candidate.getUrl(), getLayout(candidate.getLayout()), candidate.getSnapshots().isEnabled());
    }
}
项目:motech    文件:PomInformation.java   
public void parsePom(InputStream inputStream) {
    try {
        MavenXpp3Reader reader = new MavenXpp3Reader();

        Model model = reader.read(inputStream);

        if (dependencies == null) {
            dependencies = new LinkedList<>();
        }
        if (repositories == null) {
            repositories = new LinkedList<>();
        }

        parent = model.getParent();
        setPropertiesFromModel(this, model);

        for (org.apache.maven.model.Dependency dependency : model.getDependencies()) {
            if (!"test".equalsIgnoreCase(dependency.getScope())) {
                dependencies.add(new Dependency(new DefaultArtifact(
                        dependency.getGroupId(),
                        dependency.getArtifactId(),
                        dependency.getClassifier(),
                        "jar",
                        dependency.getVersion()
                ), JavaScopes.RUNTIME));
            }
        }

        for (Repository remoteRepository : model.getRepositories()) {
            repositories.add(new RemoteRepository(remoteRepository.getId(), "default", remoteRepository.getUrl()));
        }
    } catch (Exception ex) {
        LOGGER.error("Error while reading POM file", ex);
    }
}
项目:appformer    文件:POMContentHandler.java   
private ArrayList<Repository> getRepositories(final POM pom) {
    ArrayList<Repository> result = new ArrayList<Repository>();
    for (org.guvnor.common.services.project.model.Repository repository : pom.getRepositories()) {
        result.add(fromClientModelToPom(repository));
    }
    return result;
}
项目:appformer    文件:POMContentHandler.java   
private Repository fromClientModelToPom(final org.guvnor.common.services.project.model.Repository from) {
    Repository to = new Repository();
    to.setId(from.getId());
    to.setName(from.getName());
    to.setUrl(from.getUrl());

    return to;
}
项目:appformer    文件:POMContentHandler.java   
public POM toModel(final String pomAsString) throws IOException, XmlPullParserException {
    Model model = new MavenXpp3Reader().read(new StringReader(pomAsString));

    POM pomModel = new POM(
            model.getName(),
            model.getDescription(),
            new GAV(
                    (model.getGroupId() == null ? model.getParent().getGroupId() : model.getGroupId()),
                    (model.getArtifactId() == null ? model.getParent().getArtifactId() : model.getArtifactId()),
                    (model.getVersion() == null ? model.getParent().getVersion() : model.getVersion())
            )
    );

    pomModel.setPackaging(model.getPackaging());

    if (model.getParent() != null) {
        pomModel.setParent(new GAV(model.getParent().getGroupId(),
                                   model.getParent().getArtifactId(),
                                   model.getParent().getVersion()));
    }

    pomModel.getModules().clear();
    for (String module : model.getModules()) {
        pomModel.getModules().add(module);
        pomModel.setPackaging("pom");
    }
    for (Repository repository : model.getRepositories()) {
        pomModel.addRepository(fromPomModelToClientModel(repository));
    }

    pomModel.setDependencies(new DependencyContentHandler().fromPomModelToClientModel(model.getDependencies()));

    pomModel.setBuild(new BuildContentHandler().fromPomModelToClientModel(model.getBuild()));

    return pomModel;
}
项目:appformer    文件:POMContentHandler.java   
private org.guvnor.common.services.project.model.Repository fromPomModelToClientModel(final Repository from) {
    org.guvnor.common.services.project.model.Repository to = new org.guvnor.common.services.project.model.Repository();

    to.setId(from.getId());
    to.setName(from.getName());
    to.setUrl(from.getUrl());

    return to;
}
项目:maven-shade-plugin    文件:MavenJDOMWriter.java   
/**
 * Method updateRepository
 *
 * @param value
 * @param element
 * @param counter
 * @param xmlTag
 */
protected void updateRepository( Repository value, String xmlTag, Counter counter, Element element )
{
    Element root = element;
    Counter innerCount = new Counter( counter.getDepth() + 1 );
    updateRepositoryPolicy( value.getReleases(), "releases", innerCount, root );
    updateRepositoryPolicy( value.getSnapshots(), "snapshots", innerCount, root );
    findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), null );
    findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null );
    findAndReplaceSimpleElement( innerCount, root, "url", value.getUrl(), null );
    findAndReplaceSimpleElement( innerCount, root, "layout", value.getLayout(), "default" );
}
项目:developer-studio    文件:AbstractWSO2ProjectCreationWizard.java   
protected Repository getGlobalRepositoryFromPreference() {

        String repoURL =
                         preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
                                                      GLOBAL_REPOSITORY_URL, null, null);
        if (repoURL != null) {
            Repository repo = new Repository();
            repo.setUrl(repoURL);
            repo.setId(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
                                                    GLOBAL_REPOSITORY_ID, null, null));
            RepositoryPolicy releasePolicy = new RepositoryPolicy();
            String releaseEnabled =
                                    preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
                                                                 RELEASES_ENABLED, null, null);
            releasePolicy.setEnabled(releaseEnabled != null);
            releasePolicy.setUpdatePolicy(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
                                                                       RELEASES_UPDATE_POLICY, null, null));
            releasePolicy.setChecksumPolicy(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
                                                                         RELEASES_CHECKSUM_POLICY, null, null));
            repo.setReleases(releasePolicy);

            RepositoryPolicy snapshotPolicy = new RepositoryPolicy();
            String snapshotsEnabled =
                                      preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
                                                                   SNAPSHOTS_ENABLED, null, null);
            snapshotPolicy.setEnabled(snapshotsEnabled != null);
            snapshotPolicy.setUpdatePolicy(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
                                                                        SNAPSHOTS_UPDATE_POLICY, null, null));
            snapshotPolicy.setChecksumPolicy(preferencesService.getString("org.wso2.developerstudio.eclipse.platform.ui",
                                                                          SNAPSHOTS_CHECKSUM_POLICY, null, null));
            repo.setSnapshots(snapshotPolicy);

            return repo;
        }
        return null;
    }