private static void groupid(Project project, MavenPomInternal pom) { val projectIdentity = pom.getProjectIdentity(); if (!isNotEmpty(projectIdentity.getGroupId())) { if (!isNotEmpty(project.getGroup().toString())) { val topPackageName = ProjectUtilsKt.detectTopPackageName(project.getConvention()); if (topPackageName == null) { throw new IllegalStateException("There is no group set on the project, and could not auto-detect one"); } LOG.warn("Auto-detecting the group id as \"" + topPackageName + "\", but should be explicitly set on the project.\nIn build.gradle, add:\n group = \"" + topPackageName + "\""); project.setGroup(topPackageName); } projectIdentity.setGroupId(project.getGroup().toString()); } }
@TaskAction public void doGenerate() { MavenPomInternal pomInternal = (MavenPomInternal) getPom(); MavenPomFileGenerator pomGenerator = new MavenPomFileGenerator(pomInternal.getProjectIdentity(), getVersionRangeMapper()); pomGenerator.setPackaging(pomInternal.getPackaging()); for (MavenDependencyInternal runtimeDependency : pomInternal.getRuntimeDependencies()) { pomGenerator.addRuntimeDependency(runtimeDependency); } pomGenerator.withXml(pomInternal.getXmlAction()); pomGenerator.writeTo(getDestination()); }
@TaskAction public void doGenerate() { MavenPomInternal pomInternal = (MavenPomInternal) getPom(); MavenPomFileGenerator pomGenerator = new MavenPomFileGenerator(pomInternal.getProjectIdentity()); pomGenerator.setPackaging(pomInternal.getPackaging()); for (MavenDependencyInternal runtimeDependency : pomInternal.getRuntimeDependencies()) { pomGenerator.addRuntimeDependency(runtimeDependency); } pomGenerator.withXml(pomInternal.getXmlAction()); pomGenerator.writeTo(getDestination()); }
private static MavenPublication createMainPublication(Project project) { val publishing = project.getConvention().getByType(PublishingExtension.class); val pub = publishing.getPublications().create(PUBLICATION_NAME, MavenPublication.class); publishing.getRepositories().mavenLocal(); project.afterEvaluate(prj -> groupid(project, (MavenPomInternal)pub.getPom())); configPom(project, pub); return pub; }