small update

This commit is contained in:
dzj 2024-10-17 06:30:58 +08:00
parent 7edf4f59c6
commit 2c0c6c22f4
8 changed files with 183 additions and 142 deletions

View File

@ -1,51 +1,18 @@
plugins { plugins {
id 'groovy-gradle-plugin' id 'groovy-gradle-plugin' //groovy DSL
id 'com.gradle.plugin-publish' version '1.3.0' id 'com.gradle.plugin-publish' version '1.3.0' //plugin本身已经包含了Java-gradle-plugin和maven-publish
} }
repositories { group = 'net.risesoft.y9'
// Use Maven Central for resolving dependencies. version = '1.0'
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) }
}
}
}
}
}
gradlePlugin { gradlePlugin {
// Define the plugin website = 'https://svn.youshengyun.com:3000/risesoft/y9-build-logic'
plugins { vcsUrl = 'https://svn.youshengyun.com:3000/risesoft/y9-build-logic'
greeting {
id = 'org.example.greeting'
implementationClass = 'org.example.Y9BuildLogicPlugin'
}
}
} }
gradlePlugin.testSourceSets.add(sourceSets.functionalTest) // https://docs.gradle.org/current/userguide/publishing_gradle_module_metadata.html#sub:disabling-gmm-publication
tasks.withType(GenerateModuleMetadata) {
tasks.named('check') { enabled = false
// Include functionalTest as part of the check lifecycle }
dependsOn(testing.suites.functionalTest)
}

View File

@ -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);
}
}
}

View File

@ -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 = []
}
}
}

View File

@ -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}"]
}
}

View File

@ -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
}

View File

@ -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*'
}

View File

@ -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'"));
});
}
}

View File

@ -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"));
}
}