private void configureUploadArchivesTask() { configurationActionContainer.add(new Action<Project>() { public void execute(Project project) { Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(BasePlugin.UPLOAD_ARCHIVES_TASK_NAME); if (uploadArchives == null) { return; } ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration(); Module module = configuration.getModule(); for (MavenResolver resolver : uploadArchives.getRepositories().withType(MavenResolver.class)) { MavenPom pom = resolver.getPom(); ModuleVersionIdentifier publicationId = new DefaultModuleVersionIdentifier( pom.getGroupId().equals(MavenProject.EMPTY_PROJECT_GROUP_ID) ? module.getGroup() : pom.getGroupId(), pom.getArtifactId().equals(MavenProject.EMPTY_PROJECT_ARTIFACT_ID) ? module.getName() : pom.getArtifactId(), pom.getVersion().equals(MavenProject.EMPTY_PROJECT_VERSION) ? module.getVersion() : pom.getVersion() ); publicationRegistry.registerPublication(project.getPath(), new DefaultProjectPublication(publicationId)); } } }); }
private void configureUploadArchivesTask() { configurationActionContainer.add(new Action<Project>() { public void execute(Project project) { Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(BasePlugin.UPLOAD_ARCHIVES_TASK_NAME); if (uploadArchives == null) { return; } ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration(); ModuleInternal module = configuration.getModule(); for (MavenResolver resolver : uploadArchives.getRepositories().withType(MavenResolver.class)) { MavenPom pom = resolver.getPom(); ModuleVersionIdentifier publicationId = new DefaultModuleVersionIdentifier( pom.getGroupId().equals(MavenProject.EMPTY_PROJECT_GROUP_ID) ? module.getGroup() : pom.getGroupId(), pom.getArtifactId().equals(MavenProject.EMPTY_PROJECT_ARTIFACT_ID) ? module.getName() : pom.getArtifactId(), pom.getVersion().equals(MavenProject.EMPTY_PROJECT_VERSION) ? module.getVersion() : pom.getVersion() ); publicationRegistry.registerPublication(project.getPath(), new DefaultProjectPublication(publicationId)); } } }); }
private void assignArtifactValuesToPom(Artifact artifact, MavenPom pom, boolean setType) { if (pom.getGroupId().equals(MavenProject.EMPTY_PROJECT_GROUP_ID)) { pom.setGroupId(artifact.getModuleRevisionId().getOrganisation()); } if (pom.getArtifactId().equals(MavenProject.EMPTY_PROJECT_ARTIFACT_ID)) { pom.setArtifactId(artifact.getName()); } if (pom.getVersion().equals(MavenProject.EMPTY_PROJECT_VERSION)) { pom.setVersion(artifact.getModuleRevisionId().getRevision()); } if (setType) { pom.setPackaging(artifact.getType()); } }
public MavenPom addFilter(String name, PublishFilter publishFilter) { if (name == null || publishFilter == null) { throw new InvalidUserDataException("Name and Filter must not be null."); } MavenPom pom = mavenPomFactory.create(); pomFilters.put(name, new DefaultPomFilter(name, pom, publishFilter)); return pom; }
public DefaultPomFilter(String name, MavenPom pom, PublishFilter filter) { this.name = name; this.pom = pom; this.filter = filter; }
public MavenPom getPomTemplate() { return pom; }
public void setPomTemplate(MavenPom pom) { this.pom = pom; }
public MavenPom create() { return new DefaultMavenPom(configurationContainer, new DefaultConf2ScopeMappingContainer(conf2ScopeMappingContainer.getMappings()), pomDependenciesConverter, fileResolver); }
public Factory<MavenPom> createMavenPomFactory(ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer conf2ScopeMappingContainer, FileResolver fileResolver) { return new DefaultMavenPomFactory(configurationContainer, conf2ScopeMappingContainer, createPomDependenciesConverter(), fileResolver); }
public Factory<MavenPom> createMavenPomFactory(ConfigurationContainer configurationContainer, Map<Configuration, Conf2ScopeMapping> mappings, FileResolver fileResolver) { return new DefaultMavenPomFactory(configurationContainer, createConf2ScopeMappingContainer(mappings), createPomDependenciesConverter(), fileResolver); }
public DefaultMavenPom whenConfigured(final Action<MavenPom> action) { whenConfiguredActions.add(action); return this; }
private PomFilterContainer createPomFilterContainer(Factory<MavenPom> mavenPomFactory) { return new BasePomFilterContainer(mavenPomFactory); }
public DefaultArtifactPom(MavenPom pom) { this.pom = pom; }
public MavenPom getPom() { return pom; }
public ArtifactPom createArtifactPom(MavenPom pom) { return new DefaultArtifactPom(pom); }
public MavenPom getPom() { return pomFilterContainer.getPom(); }
public void setPom(MavenPom defaultPom) { pomFilterContainer.setPom(defaultPom); }
public MavenPom addFilter(String name, PublishFilter publishFilter) { return pomFilterContainer.addFilter(name, publishFilter); }
public MavenPom addFilter(String name, Closure filter) { return pomFilterContainer.addFilter(name, filter); }
public MavenPom pom(String name) { return pomFilterContainer.pom(name); }
public MavenPom pom(Closure configureClosure) { return pomFilterContainer.pom(configureClosure); }
public MavenPom pom(String name, Closure configureClosure) { return pomFilterContainer.pom(name, configureClosure); }
public BasePomFilterContainer(Factory<MavenPom> mavenPomFactory) { this.mavenPomFactory = mavenPomFactory; }
public MavenPom getPom() { return getDefaultPomFilter().getPomTemplate(); }
public void setPom(MavenPom defaultPom) { getDefaultPomFilter().setPomTemplate(defaultPom); }
public MavenPom addFilter(String name, Closure filter) { return addFilter(name, toFilter(filter)); }
public MavenPom pom(Closure configureClosure) { return ConfigureUtil.configure(configureClosure, getPom()); }
public MavenPom pom(String name, Closure configureClosure) { return ConfigureUtil.configure(configureClosure, pom(name)); }
public MavenPom pom(String name) { if (name == null) { throw new InvalidUserDataException("Name must not be null."); } return pomFilters.get(name).getPomTemplate(); }
public Factory<MavenPom> getMavenPomFactory() { return mavenPomFactory; }