-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MSAL and proprietary license plugins
- Loading branch information
1 parent
72f5a45
commit d24ad17
Showing
3 changed files
with
121 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/org/openrewrite/gradle/ModerneProprietaryLicensePlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}); | ||
}); | ||
}); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/org/openrewrite/gradle/ModerneSourceAvailableLicensePlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}); | ||
}); | ||
}); | ||
} | ||
} |