small update
This commit is contained in:
parent
7edf4f59c6
commit
2c0c6c22f4
|
@ -1,51 +1,18 @@
|
|||
plugins {
|
||||
id 'groovy-gradle-plugin'
|
||||
id 'com.gradle.plugin-publish' version '1.3.0'
|
||||
id 'groovy-gradle-plugin' //groovy DSL
|
||||
id 'com.gradle.plugin-publish' version '1.3.0' //这个plugin本身已经包含了Java-gradle-plugin和maven-publish
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Use Maven Central for resolving dependencies.
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
testing {
|
||||
suites {
|
||||
// Configure the built-in test suite
|
||||
test {
|
||||
// Use JUnit Jupiter test framework
|
||||
useJUnitJupiter('5.10.3')
|
||||
}
|
||||
|
||||
// Create a new test suite
|
||||
functionalTest(JvmTestSuite) {
|
||||
dependencies {
|
||||
// functionalTest test suite depends on the production code in tests
|
||||
implementation project()
|
||||
}
|
||||
|
||||
targets {
|
||||
all {
|
||||
// This test suite should run after the built-in test suite has run its tests
|
||||
testTask.configure { shouldRunAfter(test) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
group = 'net.risesoft.y9'
|
||||
version = '1.0'
|
||||
|
||||
gradlePlugin {
|
||||
// Define the plugin
|
||||
plugins {
|
||||
greeting {
|
||||
id = 'org.example.greeting'
|
||||
implementationClass = 'org.example.Y9BuildLogicPlugin'
|
||||
}
|
||||
}
|
||||
website = 'https://svn.youshengyun.com:3000/risesoft/y9-build-logic'
|
||||
vcsUrl = 'https://svn.youshengyun.com:3000/risesoft/y9-build-logic'
|
||||
|
||||
}
|
||||
|
||||
gradlePlugin.testSourceSets.add(sourceSets.functionalTest)
|
||||
|
||||
tasks.named('check') {
|
||||
// Include functionalTest as part of the check lifecycle
|
||||
dependsOn(testing.suites.functionalTest)
|
||||
}
|
||||
// https://docs.gradle.org/current/userguide/publishing_gradle_module_metadata.html#sub:disabling-gmm-publication
|
||||
tasks.withType(GenerateModuleMetadata) {
|
||||
enabled = false
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* This source file was generated by the Gradle 'init' task
|
||||
*/
|
||||
package org.example;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.io.FileWriter;
|
||||
import java.nio.file.Files;
|
||||
import org.gradle.testkit.runner.GradleRunner;
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* A simple functional test for the 'org.example.greeting' plugin.
|
||||
*/
|
||||
class Y9BuildLogicPluginFunctionalTest {
|
||||
@TempDir
|
||||
File projectDir;
|
||||
|
||||
private File getBuildFile() {
|
||||
return new File(projectDir, "build.gradle");
|
||||
}
|
||||
|
||||
private File getSettingsFile() {
|
||||
return new File(projectDir, "settings.gradle");
|
||||
}
|
||||
|
||||
@Test void canRunTask() throws IOException {
|
||||
writeString(getSettingsFile(), "");
|
||||
writeString(getBuildFile(),
|
||||
"plugins {" +
|
||||
" id('org.example.greeting')" +
|
||||
"}");
|
||||
|
||||
// Run the build
|
||||
GradleRunner runner = GradleRunner.create();
|
||||
runner.forwardOutput();
|
||||
runner.withPluginClasspath();
|
||||
runner.withArguments("greeting");
|
||||
runner.withProjectDir(projectDir);
|
||||
BuildResult result = runner.build();
|
||||
|
||||
// Verify the result
|
||||
assertTrue(result.getOutput().contains("Hello from plugin 'org.example.greeting'"));
|
||||
}
|
||||
|
||||
private void writeString(File file, String string) throws IOException {
|
||||
try (Writer writer = new FileWriter(file)) {
|
||||
writer.write(string);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
plugins {
|
||||
id "io.freefair.aspectj.post-compile-weaving"
|
||||
}
|
||||
|
||||
println "apply plugin 'io.freefair.aspectj.post-compile-weaving' for ${project.name}"
|
||||
|
||||
dependencies {
|
||||
api libs.org.aspectj.aspectjrt
|
||||
api libs.org.aspectj.aspectjtools
|
||||
|
||||
aspect libs.org.springframework.spring.aspects
|
||||
testAspect libs.org.springframework.spring.aspects
|
||||
}
|
||||
|
||||
compileJava {
|
||||
ajc {
|
||||
enabled = true
|
||||
classpath
|
||||
options {
|
||||
aspectpath.setFrom configurations.aspect
|
||||
compilerArgs = []
|
||||
compilerArgs += "-showWeaveInfo -verbose"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compileTestJava {
|
||||
ajc {
|
||||
enabled = true
|
||||
classpath
|
||||
options {
|
||||
aspectpath.setFrom configurations.testAspect
|
||||
compilerArgs = []
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
plugins {
|
||||
id 'com.google.cloud.tools.jib'
|
||||
}
|
||||
|
||||
println "apply plugin 'com.google.cloud.tools.jib' for ${project.name}"
|
||||
|
||||
def dateTimeStr = new Date().format("yyyyMMddHHmm")
|
||||
|
||||
jib {
|
||||
from {
|
||||
image = 'docker-internal.youshengyun.com/tomcat:10.1-jre21-temurin'
|
||||
platforms {
|
||||
platform {
|
||||
architecture = 'amd64'
|
||||
os = 'linux'
|
||||
}
|
||||
platform {
|
||||
architecture = 'arm64'
|
||||
os = 'linux'
|
||||
}
|
||||
}
|
||||
}
|
||||
// container.appRoot = "/usr/local/tomcat/webapps/app"
|
||||
to {
|
||||
image "docker-registry-internal.youshengyun.com/${project.name}"
|
||||
auth {
|
||||
username = findProperty("dockerUsername") ?: ""
|
||||
password = findProperty("dockerPassword") ?: ""
|
||||
}
|
||||
tags = ['v9.7.0-SNAPSHOT', 'v9.7.x', "v9.7.0-SNAPSHOT-${dateTimeStr}"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*
|
||||
* This project uses @Incubating APIs which are subject to change.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
id 'signing'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
url = uri('https://repo.spring.io/snapshot')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://repo.spring.io/milestone')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://maven.aliyun.com/repository/public')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://svn.youshengyun.com:9900/nexus/repository/maven-public/')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://repo.maven.apache.org/maven2/')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://build.shibboleth.net/maven/releases/')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('https://build.shibboleth.net/maven/snapshots/')
|
||||
}
|
||||
}
|
||||
|
||||
group = 'net.risesoft'
|
||||
version = 'v9.7.0-SNAPSHOT'
|
||||
java.sourceCompatibility = JavaVersion.VERSION_21
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.compilerArgs << '-parameters'
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from(components.java)
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
name = 'y9-internet-repo'
|
||||
url = 'https://svn.youshengyun.com:9900/nexus/repository/maven-snapshots/'
|
||||
credentials {
|
||||
username = findProperty("mavenUsername") ?: ""
|
||||
password = findProject("mavenPassword") ?: ""
|
||||
}
|
||||
// name = 'myRepo'
|
||||
// url = layout.buildDirectory.dir("repo")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
sign publishing.publications.maven
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
tasks.withType(Javadoc) {
|
||||
options.encoding = 'UTF-8'
|
||||
failOnError = false
|
||||
options.addStringOption('Xdoclint:none', '-quiet') // 禁用所有文档检查
|
||||
}
|
||||
|
||||
tasks.withType(GenerateModuleMetadata) {
|
||||
enabled = false
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
plugins {
|
||||
id 'com.ly.smart-doc'
|
||||
}
|
||||
|
||||
println "apply plugin 'com.ly.smart-doc' for ${project.name}"
|
||||
|
||||
smartdoc {
|
||||
configFile = file("src/main/resources/smart-doc.json")
|
||||
include 'net.risesoft*'
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
* This source file was generated by the Gradle 'init' task
|
||||
*/
|
||||
package org.example;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.Plugin;
|
||||
|
||||
/**
|
||||
* A simple 'hello world' plugin.
|
||||
*/
|
||||
public class Y9BuildLogicPlugin implements Plugin<Project> {
|
||||
public void apply(Project project) {
|
||||
// Register a task
|
||||
project.getTasks().register("greeting", task -> {
|
||||
task.doLast(s -> System.out.println("Hello from plugin 'org.example.greeting'"));
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* This source file was generated by the Gradle 'init' task
|
||||
*/
|
||||
package org.example;
|
||||
|
||||
import org.gradle.testfixtures.ProjectBuilder;
|
||||
import org.gradle.api.Project;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* A simple unit test for the 'org.example.greeting' plugin.
|
||||
*/
|
||||
class Y9BuildLogicPluginTest {
|
||||
@Test void pluginRegistersATask() {
|
||||
// Create a test project and apply the plugin
|
||||
Project project = ProjectBuilder.builder().build();
|
||||
project.getPlugins().apply("org.example.greeting");
|
||||
|
||||
// Verify the result
|
||||
assertNotNull(project.getTasks().findByName("greeting"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue