org.gradle.api.artifacts.repositories.IvyArtifactRepository Java Examples

The following examples show how to use org.gradle.api.artifacts.repositories.IvyArtifactRepository. 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: BasePlugin.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private void configureUploadArchivesTask() {
    configurationActionContainer.add(new Action<Project>() {
        public void execute(Project project) {
            Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(UPLOAD_ARCHIVES_TASK_NAME);
            if (uploadArchives == null) {
                return;
            }

            boolean hasIvyRepo = !uploadArchives.getRepositories().withType(IvyArtifactRepository.class).isEmpty();
            if (!hasIvyRepo) {
                return;
            } // Maven repos are handled by MavenPlugin

            ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration();
            Module module = configuration.getModule();
            ModuleVersionIdentifier publicationId =
                    new DefaultModuleVersionIdentifier(module.getGroup(), module.getName(), module.getVersion());
            publicationRegistry.registerPublication(module.getProjectPath(), new DefaultProjectPublication(publicationId));
        }
    });
}
 
Example #2
Source File: BasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureUploadArchivesTask() {
    configurationActionContainer.add(new Action<Project>() {
        public void execute(Project project) {
            Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(UPLOAD_ARCHIVES_TASK_NAME);
            if (uploadArchives == null) { return; }

            boolean hasIvyRepo = !uploadArchives.getRepositories().withType(IvyArtifactRepository.class).isEmpty();
            if (!hasIvyRepo) { return; } // Maven repos are handled by MavenPlugin

            ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration();
            ModuleInternal module = configuration.getModule();
            ModuleVersionIdentifier publicationId =
                    new DefaultModuleVersionIdentifier(module.getGroup(), module.getName(), module.getVersion());
            publicationRegistry.registerPublication(module.getProjectPath(), new DefaultProjectPublication(publicationId));
        }
    });
}
 
Example #3
Source File: BasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureUploadArchivesTask() {
    configurationActionContainer.add(new Action<Project>() {
        public void execute(Project project) {
            Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(UPLOAD_ARCHIVES_TASK_NAME);
            if (uploadArchives == null) { return; }

            boolean hasIvyRepo = !uploadArchives.getRepositories().withType(IvyArtifactRepository.class).isEmpty();
            if (!hasIvyRepo) { return; } // Maven repos are handled by MavenPlugin

            ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration();
            ModuleInternal module = configuration.getModule();
            ModuleVersionIdentifier publicationId =
                    new DefaultModuleVersionIdentifier(module.getGroup(), module.getName(), module.getVersion());
            publicationRegistry.registerPublication(module.getProjectPath(), new DefaultProjectPublication(publicationId));
        }
    });
}
 
Example #4
Source File: BasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureUploadArchivesTask() {
    configurationActionContainer.add(new Action<Project>() {
        public void execute(Project project) {
            Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(UPLOAD_ARCHIVES_TASK_NAME);
            if (uploadArchives == null) { return; }

            boolean hasIvyRepo = !uploadArchives.getRepositories().withType(IvyArtifactRepository.class).isEmpty();
            if (!hasIvyRepo) { return; } // Maven repos are handled by MavenPlugin

            ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration();
            ModuleInternal module = configuration.getModule();
            ModuleVersionIdentifier publicationId =
                    new DefaultModuleVersionIdentifier(module.getGroup(), module.getName(), module.getVersion());
            publicationRegistry.registerPublication(module.getProjectPath(), new DefaultProjectPublication(publicationId));
        }
    });
}
 
Example #5
Source File: BasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureUploadArchivesTask() {
    configurationActionContainer.add(new Action<Project>() {
        public void execute(Project project) {
            Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(UPLOAD_ARCHIVES_TASK_NAME);
            if (uploadArchives == null) { return; }

            boolean hasIvyRepo = !uploadArchives.getRepositories().withType(IvyArtifactRepository.class).isEmpty();
            if (!hasIvyRepo) { return; } // Maven repos are handled by MavenPlugin

            ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration();
            ModuleInternal module = configuration.getModule();
            ModuleVersionIdentifier publicationId =
                    new DefaultModuleVersionIdentifier(module.getGroup(), module.getName(), module.getVersion());
            publicationRegistry.registerPublication(module.getProjectPath(), new DefaultProjectPublication(publicationId));
        }
    });
}
 
Example #6
Source File: IvyRepositoryLayout.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(URI baseUri, PatternBasedResolver resolver) {
    if (baseUri == null) {
        return;
    }

    resolver.addArtifactLocation(baseUri, IvyArtifactRepository.IVY_ARTIFACT_PATTERN);
    resolver.addDescriptorLocation(baseUri, IvyArtifactRepository.IVY_ARTIFACT_PATTERN);
}
 
Example #7
Source File: PublishToIvyRepository.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
public void publish() {
    IvyPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }

    IvyArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }

    doPublish(publicationInternal, repository);
}
 
Example #8
Source File: PublishToIvyRepository.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void doPublish(final IvyPublicationInternal publication, final IvyArtifactRepository repository) {
    new PublishOperation(publication, repository) {
        @Override
        protected void publish() throws Exception {
            IvyNormalizedPublication normalizedPublication = publication.asNormalisedPublication();
            IvyPublisher publisher = getIvyPublisher();
            publisher.publish(normalizedPublication, Cast.cast(PublicationAwareRepository.class, repository));
        }
    }.run();
}
 
Example #9
Source File: GradleRepositoryLayout.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(URI baseUri, PatternBasedResolver resolver) {
    if (baseUri == null) {
        return;
    }

    resolver.addArtifactLocation(baseUri, IvyArtifactRepository.GRADLE_ARTIFACT_PATTERN);
    resolver.addDescriptorLocation(baseUri, IvyArtifactRepository.GRADLE_IVY_PATTERN);
}
 
Example #10
Source File: MavenRepositoryLayout.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(URI baseUri, PatternBasedResolver resolver) {
    if (baseUri == null) {
        return;
    }

    resolver.setM2compatible(true); // Replace '.' with '/' in organisation

    resolver.addArtifactLocation(baseUri, IvyArtifactRepository.MAVEN_ARTIFACT_PATTERN);
    resolver.addDescriptorLocation(baseUri, IvyArtifactRepository.MAVEN_IVY_PATTERN);
}
 
Example #11
Source File: IvyRepositoryLayout.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(URI baseUri, PatternBasedResolver resolver) {
    if (baseUri == null) {
        return;
    }

    resolver.addArtifactLocation(baseUri, IvyArtifactRepository.IVY_ARTIFACT_PATTERN);
    resolver.addDescriptorLocation(baseUri, IvyArtifactRepository.IVY_ARTIFACT_PATTERN);
}
 
Example #12
Source File: IvyPublicationTasksModelRule.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void createTasks(TaskContainer tasks, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        GenerateIvyDescriptor descriptorTask = tasks.create(descriptorTaskName, GenerateIvyDescriptor.class);
        descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
        descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
        descriptorTask.setDescriptor(publication.getDescriptor());

        ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
        descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
            public Object call() throws Exception {
                return new File(project.getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
            }
        });

        publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());

        for (IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            PublishToIvyRepository publishTask = tasks.create(publishTaskName, PublishToIvyRepository.class);
            publishTask.setPublication(publication);
            publishTask.setRepository(repository);
            publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName));

            tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME).dependsOn(publishTask);
        }
    }
}
 
Example #13
Source File: PublishToIvyRepository.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void doPublish(final IvyPublicationInternal publication, final IvyArtifactRepository repository) {
    new PublishOperation(publication, repository) {
        @Override
        protected void publish() throws Exception {
            IvyNormalizedPublication normalizedPublication = publication.asNormalisedPublication();
            IvyPublisher publisher = new DependencyResolverIvyPublisher();
            publisher = new ValidatingIvyPublisher(publisher);
            publisher = new ContextualizingIvyPublisher(publisher, getServices().get(IvyContextManager.class));
            publisher.publish(normalizedPublication, Cast.cast(PublicationAwareRepository.class, repository));
        }
    }.run();
}
 
Example #14
Source File: PublishToIvyRepository.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
public void publish() {
    IvyPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }

    IvyArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }

    doPublish(publicationInternal, repository);
}
 
Example #15
Source File: GradleRepositoryLayout.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(URI baseUri, PatternBasedResolver resolver) {
    if (baseUri == null) {
        return;
    }

    resolver.addArtifactLocation(baseUri, IvyArtifactRepository.GRADLE_ARTIFACT_PATTERN);
    resolver.addDescriptorLocation(baseUri, IvyArtifactRepository.GRADLE_IVY_PATTERN);
}
 
Example #16
Source File: MavenRepositoryLayout.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(URI baseUri, PatternBasedResolver resolver) {
    if (baseUri == null) {
        return;
    }

    resolver.setM2compatible(true); // Replace '.' with '/' in organisation

    resolver.addArtifactLocation(baseUri, IvyArtifactRepository.MAVEN_ARTIFACT_PATTERN);
    resolver.addDescriptorLocation(baseUri, IvyArtifactRepository.MAVEN_IVY_PATTERN);
}
 
Example #17
Source File: MavenRepositoryLayout.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(URI baseUri, PatternBasedResolver resolver) {
    if (baseUri == null) {
        return;
    }

    resolver.setM2compatible(true); // Replace '.' with '/' in organisation

    resolver.addArtifactLocation(baseUri, IvyArtifactRepository.MAVEN_ARTIFACT_PATTERN);
    resolver.addDescriptorLocation(baseUri, IvyArtifactRepository.MAVEN_IVY_PATTERN);
}
 
Example #18
Source File: GradleRepositoryLayout.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(URI baseUri, PatternBasedResolver resolver) {
    if (baseUri == null) {
        return;
    }

    resolver.addArtifactLocation(baseUri, IvyArtifactRepository.GRADLE_ARTIFACT_PATTERN);
    resolver.addDescriptorLocation(baseUri, IvyArtifactRepository.GRADLE_IVY_PATTERN);
}
 
Example #19
Source File: PublishToIvyRepository.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
public void publish() {
    IvyPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }

    IvyArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }

    doPublish(publicationInternal, repository);
}
 
Example #20
Source File: PublishToIvyRepository.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void doPublish(final IvyPublicationInternal publication, final IvyArtifactRepository repository) {
    new PublishOperation(publication, repository) {
        @Override
        protected void publish() throws Exception {
            IvyNormalizedPublication normalizedPublication = publication.asNormalisedPublication();
            IvyPublisher publisher = new DependencyResolverIvyPublisher();
            publisher = new ValidatingIvyPublisher(publisher);
            publisher = new ContextualizingIvyPublisher(publisher, getServices().get(IvyContextManager.class));
            publisher.publish(normalizedPublication, Cast.cast(PublicationAwareRepository.class, repository));
        }
    }.run();
}
 
Example #21
Source File: IvyPublicationTasksModelRule.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void createTasks(TaskContainer tasks, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        GenerateIvyDescriptor descriptorTask = tasks.create(descriptorTaskName, GenerateIvyDescriptor.class);
        descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
        descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
        descriptorTask.setDescriptor(publication.getDescriptor());

        ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
        descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
            public Object call() throws Exception {
                return new File(project.getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
            }
        });

        publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());

        for (IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            PublishToIvyRepository publishTask = tasks.create(publishTaskName, PublishToIvyRepository.class);
            publishTask.setPublication(publication);
            publishTask.setRepository(repository);
            publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName));

            tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME).dependsOn(publishTask);
        }
    }
}
 
Example #22
Source File: PublishToIvyRepository.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void doPublish(final IvyPublicationInternal publication, final IvyArtifactRepository repository) {
    new PublishOperation(publication, repository) {
        @Override
        protected void publish() throws Exception {
            IvyNormalizedPublication normalizedPublication = publication.asNormalisedPublication();
            IvyPublisher publisher = getIvyPublisher();
            publisher.publish(normalizedPublication, Cast.cast(PublicationAwareRepository.class, repository));
        }
    }.run();
}
 
Example #23
Source File: PublishToIvyRepository.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
public void publish() {
    IvyPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }

    IvyArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }

    doPublish(publicationInternal, repository);
}
 
Example #24
Source File: GradleRepositoryLayout.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(URI baseUri, PatternBasedResolver resolver) {
    if (baseUri == null) {
        return;
    }

    resolver.addArtifactLocation(baseUri, IvyArtifactRepository.GRADLE_ARTIFACT_PATTERN);
    resolver.addDescriptorLocation(baseUri, IvyArtifactRepository.GRADLE_IVY_PATTERN);
}
 
Example #25
Source File: MavenRepositoryLayout.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(URI baseUri, PatternBasedResolver resolver) {
    if (baseUri == null) {
        return;
    }

    resolver.setM2compatible(true); // Replace '.' with '/' in organisation

    resolver.addArtifactLocation(baseUri, IvyArtifactRepository.MAVEN_ARTIFACT_PATTERN);
    resolver.addDescriptorLocation(baseUri, IvyArtifactRepository.MAVEN_IVY_PATTERN);
}
 
Example #26
Source File: JdkDownloadPlugin.java    From crate with Apache License 2.0 5 votes vote down vote up
private static Configuration maybeCreateRepositoryAndDownloadConfiguration(Project rootProject, Jdk jdk) {
    RepositoryHandler repositories = rootProject.getRepositories();
    String repoUrl;
    String artifactPattern;
    if (jdk.vendor().equals("adoptopenjdk")) {
        repoUrl = "https://cdn.crate.io/downloads/openjdk/";
        artifactPattern = String.format(
            Locale.ENGLISH,
            "OpenJDK%sU-jdk_[module]_hotspot_[revision]_%s.[ext]",
            jdk.major(),
            jdk.build()
        );
    } else {
        throw new GradleException("Unknown JDK vendor [" + jdk.vendor() + "]");
    }

    // Define the appropriate repository for the given JDK vendor and version
    var repoName = REPO_NAME_PREFIX + jdk.vendor() + "_" + jdk.version();
    if (rootProject.getRepositories().findByName(repoName) == null) {
        repositories.ivy(ivyRepo -> {
            ivyRepo.setName(repoName);
            ivyRepo.setUrl(repoUrl);
            ivyRepo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
            ivyRepo.patternLayout(layout -> layout.artifact(artifactPattern));
            ivyRepo.content(content -> content.includeGroup(jdk.vendor()));
        });
    }

    // Declare a configuration and dependency from which to download the remote JDK
    var downloadConfigName = configName(jdk.vendor(), jdk.version(), jdk.platform());
    var downloadConfiguration = rootProject.getConfigurations().maybeCreate(downloadConfigName);
    rootProject.getDependencies().add(downloadConfigName, dependencyNotation(jdk));
    return downloadConfiguration;
}
 
Example #27
Source File: JavaScriptRepositoriesExtension.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public IvyArtifactRepository googleApis() {
    return googleApis(Actions.doNothing());
}
 
Example #28
Source File: JavaScriptRepositoriesExtension.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public IvyArtifactRepository googleApis() {
    return googleApis(Actions.doNothing());
}
 
Example #29
Source File: DefaultRepositoryHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public IvyArtifactRepository ivy(Action<? super IvyArtifactRepository> action) {
    return addRepository(repositoryFactory.createIvyRepository(), IVY_REPO_DEFAULT_NAME, action);
}
 
Example #30
Source File: DefaultRepositoryHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public IvyArtifactRepository ivy(Closure closure) {
    return ivy(new ClosureBackedAction<IvyArtifactRepository>(closure));
}