Skip to content

Commit

Permalink
Add MSAL and proprietary license plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Dec 14, 2024
1 parent 72f5a45 commit d24ad17
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 9 deletions.
34 changes: 25 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,29 @@ gradlePlugin {
create("build-recipe-library-base") {
id = "org.openrewrite.build.recipe-library-base"
displayName = "Rewrite recipe library base"
description = "Builds recipe libraries with the minimum of opinions or conventions about any other aspect of the build. " +
"Does not configure artifact repositories or publishing. " +
"Use org.openrewrite.build.recipe-library if you want to build a recipe library as OSS."
description =
"Builds recipe libraries with the minimum of opinions or conventions about any other aspect of the build. " +
"Does not configure artifact repositories or publishing. " +
"Use org.openrewrite.build.recipe-library if you want to build a recipe library as OSS."
implementationClass = "org.openrewrite.gradle.RewriteRecipeLibraryBasePlugin"
tags = listOf("rewrite", "refactoring")
}
create("build-recipe-repositories") {
id = "org.openrewrite.build.recipe-repositories"
displayName = "Rewrite recipe repositories"
description = "Configures the repositories that OpenRewrite modules in open source draw dependencies from, " +
"such as Maven Central and Nexus Snapshots. "
description =
"Configures the repositories that OpenRewrite modules in open source draw dependencies from, " +
"such as Maven Central and Nexus Snapshots. "
implementationClass = "org.openrewrite.gradle.RewriteDependencyRepositoriesPlugin"
tags = listOf("rewrite", "refactoring", "oss")
}
create("build-recipe-library") {
id = "org.openrewrite.build.recipe-library"
displayName = "Rewrite recipe library"
description = "Builds recipe libraries with all the conventions and configuration used in OpenRewrite repositories. " +
"Includes conventions around which repositories to draw from and publish to. " +
"Use org.openrewrite.build.recipe-library-base if you want to build a private recipe library."
description =
"Builds recipe libraries with all the conventions and configuration used in OpenRewrite repositories. " +
"Includes conventions around which repositories to draw from and publish to. " +
"Use org.openrewrite.build.recipe-library-base if you want to build a private recipe library."
implementationClass = "org.openrewrite.gradle.RewriteRecipeLibraryPlugin"
tags = listOf("rewrite", "refactoring", "oss")
}
Expand Down Expand Up @@ -123,14 +126,27 @@ gradlePlugin {
implementationClass = "org.openrewrite.gradle.RewriteRecipeAuthorAttributionPlugin"
tags = listOf("rewrite", "refactoring")
}

create("build-recipe-examples") {
id = "org.openrewrite.build.recipe-examples"
displayName = "Rewrite recipe examples"
description = "Produces a `/META-INF/rewrite/recipe-example.yml` file containing recipe examples"
implementationClass = "org.openrewrite.gradle.RewriteRecipeExamplesPlugin"
tags = listOf("rewrite", "refactoring")
}
create("moderne-source-available-license") {
id = "org.openrewrite.build.moderne-source-available-license"
displayName = "Moderne Source Available License"
description = "Applies the MSAL to the project"
implementationClass = "org.openrewrite.gradle.ModerneSourceAvailableLicensePlugin"
tags = listOf("rewrite", "refactoring")
}
create("moderne-proprietary-license") {
id = "org.openrewrite.build.moderne-proprietary-license"
displayName = "Moderne Proprietary License"
description = "Applies the Moderne Proprietary License to the project"
implementationClass = "org.openrewrite.gradle.ModerneProprietaryLicensePlugin"
tags = listOf("rewrite", "refactoring")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2024 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openrewrite.gradle;

import nebula.plugin.publishing.maven.MavenBasePublishPlugin;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.maven.MavenPublication;
import org.gradle.jvm.tasks.Jar;

public class ModerneProprietaryLicensePlugin implements Plugin<Project> {

@Override
public void apply(Project project) {
// Empty JARs are OK: https://central.sonatype.org/publish/requirements/#supply-javadoc-and-sources
Jar sourceJar = project.getTasks().create("emptySourceJar", Jar.class, task -> {
task.from("README.md");
task.getArchiveClassifier().set("sources");
});

project.getPlugins().apply(MavenBasePublishPlugin.class);
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
publishing.publications(publications -> publications.withType(MavenPublication.class,
p -> configureLicense(p, sourceJar)));
}

private void configureLicense(MavenPublication publication, Jar sourceJar) {
publication.artifact(sourceJar);

publication.pom(pom -> {
pom.licenses(licenses -> {
licenses.license(license -> {
license.getName().set("Moderne Proprietary License");
license.getUrl().set("https://docs.moderne.io/licensing/overview");
});
});
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2024 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openrewrite.gradle;

import nebula.plugin.publishing.maven.MavenBasePublishPlugin;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.maven.MavenPublication;

public class ModerneSourceAvailableLicensePlugin implements Plugin<Project> {

@Override
public void apply(Project project) {
project.getPlugins().apply(MavenBasePublishPlugin.class);
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
publishing.publications(publications -> publications.withType(MavenPublication.class, this::configureLicense));
}

private void configureLicense(MavenPublication publication) {
publication.pom(pom -> {
pom.licenses(licenses -> {
licenses.license(license -> {
license.getName().set("Moderne Source Available License");
license.getUrl().set("https://docs.moderne.io/licensing/moderne-source-available-license");
});
});
});
}
}

0 comments on commit d24ad17

Please sign in to comment.