private void createPublishTasksForEachMavenRepo(ModelMap<Task> tasks, PublishingExtension extension, final Task publishLifecycleTask, final MavenPublicationInternal publication, final String publicationName) { for (final MavenArtifactRepository repository : extension.getRepositories().withType(MavenArtifactRepository.class)) { final String repositoryName = repository.getName(); String publishTaskName = "publish" + capitalize(publicationName) + "PublicationTo" + capitalize(repositoryName) + "Repository"; tasks.create(publishTaskName, PublishToMavenRepository.class, new Action<PublishToMavenRepository>() { public void execute(PublishToMavenRepository publishTask) { publishTask.setPublication(publication); publishTask.setRepository(repository); publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); publishTask.setDescription("Publishes Maven publication '" + publicationName + "' to Maven repository '" + repositoryName + "'."); } }); publishLifecycleTask.dependsOn(publishTaskName); } }
private ClassPath resolvePluginDependencies(final PluginUseMetaData metadata) { DependencyResolutionServices resolution = dependencyResolutionServicesFactory.create(); RepositoryHandler repositories = resolution.getResolveRepositoryHandler(); final String repoUrl = metadata.implementation.get("repo"); repositories.maven(new Action<MavenArtifactRepository>() { public void execute(MavenArtifactRepository mavenArtifactRepository) { mavenArtifactRepository.setUrl(repoUrl); } }); Dependency dependency = resolution.getDependencyHandler().create(metadata.implementation.get("gav")); ConfigurationContainerInternal configurations = (ConfigurationContainerInternal) resolution.getConfigurationContainer(); ConfigurationInternal configuration = configurations.detachedConfiguration(dependency); try { Set<File> files = configuration.getResolvedConfiguration().getFiles(Specs.satisfyAll()); return new DefaultClassPath(files); } catch (ResolveException e) { throw new DependencyResolutionException("Failed to resolve all plugin dependencies from " + repoUrl, e.getCause()); } }
@Override protected ArtifactRepository internalCreateArtifactRepository(RepositoryHandler repositoryHandler) { return repositoryHandler.maven(new Action<MavenArtifactRepository>() { @Override public void execute(MavenArtifactRepository mavenArtifactRepository) { mavenArtifactRepository.setName(getArtifactRepositoryName()); mavenArtifactRepository.setUrl(getUrl()); Credentials credentials = authenticationSupport().getConfiguredCredentials(); if (credentials != null) { ((AuthenticationSupportedInternal)mavenArtifactRepository).setConfiguredCredentials(credentials); mavenArtifactRepository.authentication(new Action<AuthenticationContainer>() { @Override public void execute(AuthenticationContainer authenticationContainer) { authenticationContainer.addAll(authenticationSupport().getConfiguredAuthentication()); } }); } } }); }
@Mutate public void createAndroidTasks( ModelMap<Task> tasks, ModelMap<AndroidComponentSpec> androidSpecs, TaskManager taskManager, SdkHandler sdkHandler, Project project, AndroidComponentModelSourceSet androidSources) { // setup SDK repositories. for (final File file : sdkHandler.getSdkLoader().getRepositories()) { project.getRepositories().maven(new Action<MavenArtifactRepository>() { @Override public void execute(MavenArtifactRepository repo) { repo.setUrl(file.toURI()); } }); } // TODO: determine how to provide functionalities of variant API objects. }
private void createPublishTasksForEachMavenRepo(CollectionBuilder<Task> tasks, PublishingExtension extension, final Task publishLifecycleTask, final MavenPublicationInternal publication, final String publicationName) { for (final MavenArtifactRepository repository : extension.getRepositories().withType(MavenArtifactRepository.class)) { final String repositoryName = repository.getName(); String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName)); tasks.create(publishTaskName, PublishToMavenRepository.class, new Action<PublishToMavenRepository>() { public void execute(PublishToMavenRepository publishTask) { publishTask.setPublication(publication); publishTask.setRepository(repository); publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); publishTask.setDescription(String.format("Publishes Maven publication '%s' to Maven repository '%s'.", publicationName, repositoryName)); //Because dynamic rules are not yet implemented we have to violate input immutability here as an interim step publishLifecycleTask.dependsOn(publishTask); } }); } }
public DependencyResolver mavenRepo(Map<String, ?> args, Closure configClosure) { DeprecationLogger.nagUserOfReplacedMethod("RepositoryHandler.mavenRepo()", "maven()"); Map<String, Object> modifiedArgs = new HashMap<String, Object>(args); if (modifiedArgs.containsKey("urls")) { List<?> urls = flattenCollections(modifiedArgs.remove("urls")); if (!urls.isEmpty()) { modifiedArgs.put("url", urls.get(0)); List<?> extraUrls = urls.subList(1, urls.size()); modifiedArgs.put("artifactUrls", extraUrls); } } MavenArtifactRepository repository = repositoryFactory.createMavenRepository(); ConfigureUtil.configureByMap(modifiedArgs, repository); DependencyResolver resolver = repositoryFactory.toResolver(repository); ConfigureUtil.configure(configClosure, resolver); addRepository(repositoryFactory.createResolverBackedRepository(resolver), "mavenRepo"); return resolver; }
@TaskAction public void publish() { MavenPublicationInternal publicationInternal = getPublicationInternal(); if (publicationInternal == null) { throw new InvalidUserDataException("The 'publication' property is required"); } MavenArtifactRepository repository = getRepository(); if (repository == null) { throw new InvalidUserDataException("The 'repository' property is required"); } doPublish(publicationInternal, repository); }
private void doPublish(final MavenPublicationInternal publication, final MavenArtifactRepository repository) { new PublishOperation(publication, repository.getName()) { @Override protected void publish() throws Exception { MavenPublisher remotePublisher = new MavenRemotePublisher(getLoggingManagerFactory(), getMavenRepositoryLocator(), getTemporaryDirFactory(), getRepositoryTransportFactory()); MavenPublisher staticLockingPublisher = new StaticLockingMavenPublisher(remotePublisher); MavenPublisher validatingPublisher = new ValidatingMavenPublisher(staticLockingPublisher); validatingPublisher.publish(publication.asNormalisedPublication(), repository); } }.run(); }
public GradleWagonMavenDeployAction(File pomFile, MavenArtifactRepository artifactRepository, RepositoryTransportFactory repositoryTransportFactory) { super(pomFile, null); this.artifactRepository = artifactRepository; this.repositoryTransportFactory = repositoryTransportFactory; registerWagonProtocols(); }
public void publish(MavenNormalizedPublication publication, MavenArtifactRepository artifactRepository) { validateIdentity(publication); validateArtifacts(publication); checkNoDuplicateArtifacts(publication); delegate.publish(publication, artifactRepository); }
public void publish(MavenNormalizedPublication publication, MavenArtifactRepository artifactRepository) { STATIC_LOCK.lock(); try { delegate.publish(publication, artifactRepository); } finally { STATIC_LOCK.unlock(); } }
public MavenArtifactRepository gradle(final Action<? super MavenArtifactRepository> action) { return repositories.maven(new Action<MavenArtifactRepository>() { public void execute(MavenArtifactRepository repository) { repository.setName("gradleJs"); repository.setUrl(GRADLE_PUBLIC_JAVASCRIPT_REPO_URL); action.execute(repository); } }); }
@Override public ArtifactRepository createArtifactRepository(RepositoryHandler repositoryHandler) { return repositoryHandler.maven(new Action<MavenArtifactRepository>() { @Override public void execute(MavenArtifactRepository mavenArtifactRepository) { mavenArtifactRepository.setUrl("https://plugins.gradle.org/m2"); } }); }
public MavenArtifactRepository createMavenLocalRepository() { MavenArtifactRepository mavenRepository = instantiator.newInstance(DefaultMavenLocalArtifactRepository.class, fileResolver, transportFactory, locallyAvailableResourceFinder, instantiator, artifactFileStore, pomParser, createAuthenticationContainer()); final File localMavenRepository = localMavenRepositoryLocator.getLocalMavenRepository(); mavenRepository.setUrl(localMavenRepository); return mavenRepository; }
@Override public MavenArtifactRepository getRepository() { if (super.getRepository() == null) { // Instantiate the default MavenLocal repository if none has been set explicitly MavenArtifactRepository mavenLocalRepository = getBaseRepositoryFactory().createMavenLocalRepository(); mavenLocalRepository.setName(ArtifactRepositoryContainer.DEFAULT_MAVEN_LOCAL_REPO_NAME); setRepository(mavenLocalRepository); } return super.getRepository(); }
@Override protected void doPublish(final MavenPublicationInternal publication, final MavenArtifactRepository repository) { new PublishOperation(publication, repository) { @Override protected void publish() throws Exception { MavenPublisher antBackedPublisher = new AntTaskBackedMavenLocalPublisher(getLoggingManagerFactory(), getTemporaryDirFactory()); MavenPublisher staticLockingPublisher = new StaticLockingMavenPublisher(antBackedPublisher); MavenPublisher validatingPublisher = new ValidatingMavenPublisher(staticLockingPublisher); validatingPublisher.publish(publication.asNormalisedPublication(), repository); } }.run(); }
protected void doPublish(final MavenPublicationInternal publication, final MavenArtifactRepository repository) { new PublishOperation(publication, repository) { @Override protected void publish() throws Exception { MavenPublisher antBackedPublisher = new AntTaskBackedMavenPublisher(getLoggingManagerFactory(), getTemporaryDirFactory()); MavenPublisher staticLockingPublisher = new StaticLockingMavenPublisher(antBackedPublisher); MavenPublisher validatingPublisher = new ValidatingMavenPublisher(staticLockingPublisher); validatingPublisher.publish(publication.asNormalisedPublication(), repository); } }.run(); }
public void publish(MavenNormalizedPublication publication, MavenArtifactRepository artifactRepository) { logger.info("Publishing to repository {}", artifactRepository); T deployTask = createDeployTask(); deployTask.setProject(AntUtil.createProject()); MavenSettingsSupplier mavenSettingsSupplier = new EmptyMavenSettingsSupplier(); mavenSettingsSupplier.supply(deployTask); postConfigure(deployTask, artifactRepository); addPomAndArtifacts(deployTask, publication); execute(deployTask); mavenSettingsSupplier.done(); }
public MavenArtifactRepository createMavenLocalRepository() { MavenArtifactRepository mavenRepository = instantiator.newInstance(DefaultMavenLocalArtifactRepository.class, fileResolver, createPasswordCredentials(), transportFactory, locallyAvailableResourceFinder, artifactFileStore); final File localMavenRepository = localMavenRepositoryLocator.getLocalMavenRepository(); mavenRepository.setUrl(localMavenRepository); return mavenRepository; }
@Override public MavenArtifactRepository getRepository() { if (super.getRepository() == null) { // Instantiate the default MavenLocal repository if none has been set explicitly MavenArtifactRepository mavenLocalRepository = baseRepositoryFactory.createMavenLocalRepository(); mavenLocalRepository.setName(ArtifactRepositoryContainer.DEFAULT_MAVEN_LOCAL_REPO_NAME); setRepository(mavenLocalRepository); } return super.getRepository(); }
protected void doPublish(final MavenPublicationInternal publication, final MavenArtifactRepository repository) { new PublishOperation(publication, repository) { @Override protected void publish() throws Exception { MavenPublisher antBackedPublisher = new AntTaskBackedMavenPublisher(loggingManagerFactory, getTemporaryDirFactory()); MavenPublisher staticLockingPublisher = new StaticLockingMavenPublisher(antBackedPublisher); MavenPublisher validatingPublisher = new ValidatingMavenPublisher(staticLockingPublisher); validatingPublisher.publish(publication.asNormalisedPublication(), repository); } }.run(); }
private void createPublishTasksForEachMavenRepo(TaskContainer tasks, PublishingExtension extension, MavenPublicationInternal publication, String publicationName) { for (MavenArtifactRepository repository : extension.getRepositories().withType(MavenArtifactRepository.class)) { String repositoryName = repository.getName(); String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName)); PublishToMavenRepository publishTask = tasks.create(publishTaskName, PublishToMavenRepository.class); publishTask.setPublication(publication); publishTask.setRepository(repository); publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP); publishTask.setDescription(String.format("Publishes Maven publication '%s' to Maven repository '%s'.", publicationName, repositoryName)); publishLifecycleTask.dependsOn(publishTask); } }
public MavenArtifactRepository mavenCentral(Map<String, ?> args) { Map<String, Object> modifiedArgs = new HashMap<String, Object>(args); if (modifiedArgs.containsKey("urls")) { DeprecationLogger.nagUserOfDeprecated( "The 'urls' property of the RepositoryHandler.mavenCentral() method", "You should use the 'artifactUrls' property to define additional artifact locations" ); List<?> urls = flattenCollections(modifiedArgs.remove("urls")); modifiedArgs.put("artifactUrls", urls); } return addRepository(repositoryFactory.createMavenCentralRepository(), DEFAULT_MAVEN_CENTRAL_REPO_NAME, new ConfigureByMapAction<MavenArtifactRepository>(modifiedArgs)); }
public GradleArtifactResolvingHelper(Project project) { this.project = project; this.project.getRepositories().maven(new Action<MavenArtifactRepository>() { @Override public void execute(MavenArtifactRepository repo) { repo.setName("jboss-public"); repo.setUrl("http://repository.jboss.org/nexus/content/groups/public/"); } }); }
@Override public void execute(DependencyResolveDetails dependencyResolveDetails) { String group = dependencyResolveDetails.getTarget().getGroup(); String name = dependencyResolveDetails.getTarget().getName(); if (aetherPlugin.getVersionMap().containsKey(group) && aetherPlugin.getVersionMap().get(group).containsKey(name)) { if (dependencyResolveDetails.getRequested().getVersion().equals(dependencyResolveDetails.getTarget().getVersion())) { dependencyResolveDetails.useVersion(aetherPlugin.getVersionMap().get(group).get(name)); } } else { RepositorySystem system = setupRepositorySystem(); RepositorySystemSession session = setupSession(project, system); List<RemoteRepository> remoteRepositories = new ArrayList<>(); for (ArtifactRepository artifactRepository : project.getRepositories()) { if (artifactRepository instanceof MavenArtifactRepository) { MavenArtifactRepository mavenArtifactRepository = (MavenArtifactRepository) artifactRepository; remoteRepositories.add(new RemoteRepository.Builder(mavenArtifactRepository.getName(), "default", mavenArtifactRepository.getUrl().toString()).build()); } } Artifact artifact = new DefaultArtifact(dependencyResolveDetails.getTarget().getGroup() + ":" + dependencyResolveDetails.getTarget().getName() + ":" + dependencyResolveDetails.getTarget().getVersion()); CollectRequest collectRequest = new CollectRequest(); String scope; if (configuration.getName().contains("test")) { scope = JavaScopes.TEST; } else if (configuration.getName().contains("runtime")) { scope = JavaScopes.RUNTIME; } else if (configuration.getName().equals("providedCompile") || configuration.getName().equals("compileOnly")) { scope = JavaScopes.PROVIDED; } else scope = JavaScopes.COMPILE; collectRequest.setRoot(new Dependency(artifact, scope)); collectRequest.setRepositories(remoteRepositories); try { CollectResult collectResult = system.collectDependencies(session, collectRequest); processDependencyNode(collectResult.getRoot()); } catch (DependencyCollectionException e) { e.printStackTrace(); } } }
protected MavenPublishAction createDeployTask(File pomFile, LocalMavenRepositoryLocator mavenRepositoryLocator, MavenArtifactRepository artifactRepository) { GradleWagonMavenDeployAction deployTask = new GradleWagonMavenDeployAction(pomFile, artifactRepository, repositoryTransportFactory); deployTask.setLocalMavenRepositoryLocation(temporaryDirFactory.create()); deployTask.setRepositories(createMavenRemoteRepository(artifactRepository), null); return deployTask; }
private RemoteRepository createMavenRemoteRepository(MavenArtifactRepository repository) { RemoteRepository remoteRepository = new RemoteRepository(); remoteRepository.setUrl(repository.getUrl().toString()); return remoteRepository; }
private RepositoryTransportWagonAdapter createAdapter(String protocol, MavenArtifactRepository artifactRepository, RepositoryTransportFactory repositoryTransportFactory) { RepositoryTransport transport = repositoryTransportFactory.createTransport(protocol, artifactRepository.getName(), ((AuthenticationSupportedInternal)artifactRepository).getConfiguredAuthentication()); URI rootUri = artifactRepository.getUrl(); return new RepositoryTransportWagonAdapter(transport, rootUri); }