-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add JRE 8 support for spring webmvc
- Loading branch information
1 parent
f95c259
commit 8167835
Showing
10 changed files
with
512 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
rootProject.name = "javite" | ||
|
||
include("vite-spring-webmvc") | ||
include("vite-spring-webmvc-jre8") |
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,117 @@ | ||
import com.vanniktech.maven.publish.JavaLibrary | ||
import com.vanniktech.maven.publish.JavadocJar | ||
import com.vanniktech.maven.publish.SonatypeHost | ||
|
||
plugins { | ||
`java-library` | ||
alias(libs.plugins.publish.maven) | ||
} | ||
|
||
description = "Vite - Spring Web MVC for JRE 8" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
tasks.withType<JavaCompile> { | ||
options.release.set(8) | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation(libs.jre8.spring.core) | ||
implementation(libs.jre8.spring.webmvc) | ||
implementation(libs.jre8.spring.boot.starter) | ||
implementation(libs.jre8.spring.boot.starter.web) | ||
implementation(libs.jre8.jackson.databind) | ||
|
||
compileOnly(libs.jre8.javax.servlet) | ||
compileOnly(libs.jre8.javax.servlet.jsp) | ||
|
||
annotationProcessor(libs.jre8.spring.boot.configuration.processor) | ||
} | ||
|
||
tasks.jar { | ||
enabled = true | ||
archiveClassifier.set("") | ||
manifest { | ||
attributes( | ||
mapOf( | ||
"Implementation-Title" to project.name, | ||
"Implementation-Version" to project.version, | ||
), | ||
) | ||
} | ||
} | ||
|
||
mavenPublishing { | ||
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) | ||
|
||
signAllPublications() | ||
} | ||
|
||
object Meta { | ||
const val DESC = "Vite integration with Spring Web MVC for JRE8." | ||
const val LICENSE = "MIT" | ||
const val LICENSE_URL = "https://opensource.org/licenses/mit" | ||
const val GITHUB_REPO = "benny123tw/javite" | ||
const val DEVELOPER_ID = "benny123tw" | ||
const val DEVELOPER_NAME = "Benny Yen" | ||
const val DEVELOPER_ORGANIZATION = "io.github.benny123tw" | ||
const val DEVELOPER_ORGANIZATION_URL = "https://www.github.com/benny123tw" | ||
} | ||
|
||
mavenPublishing { | ||
println("Publish ${project.group}, ${project.name}, ${project.version}") | ||
coordinates(project.group.toString(), project.name, project.version.toString()) | ||
|
||
// Correctly configure JavaLibrary with Javadoc and sources JARs | ||
configure( | ||
JavaLibrary( | ||
javadocJar = JavadocJar.Javadoc(), | ||
sourcesJar = true | ||
) | ||
) | ||
|
||
pom { | ||
name.set(project.name) | ||
description.set(Meta.DESC) | ||
inceptionYear.set("2024") | ||
url.set(Meta.GITHUB_REPO) | ||
licenses { | ||
license { | ||
name.set(Meta.LICENSE) | ||
url.set(Meta.LICENSE_URL) | ||
} | ||
} | ||
developers { | ||
developer { | ||
id.set(Meta.DEVELOPER_ID) | ||
name.set(Meta.DEVELOPER_NAME) | ||
organization.set(Meta.DEVELOPER_ORGANIZATION) | ||
organizationUrl.set(Meta.DEVELOPER_ORGANIZATION_URL) | ||
} | ||
} | ||
scm { | ||
url.set("https://github.com/${Meta.GITHUB_REPO}.git") | ||
connection.set("scm:git:git://github.com/${Meta.GITHUB_REPO}.git") | ||
developerConnection.set("scm:git:git://github.com/${Meta.GITHUB_REPO}.git") | ||
} | ||
issueManagement { | ||
url.set("https://github.com/${Meta.GITHUB_REPO}/issues") | ||
} | ||
} | ||
} | ||
|
||
// gradle locking of dependency versions | ||
// *required+used for trivy scan | ||
dependencyLocking { | ||
lockAllConfigurations() | ||
} | ||
|
||
// always run subproject task with parent | ||
rootProject.tasks.dependencies { dependsOn(tasks.dependencies) } |
16 changes: 16 additions & 0 deletions
16
...-spring-webmvc-jre8/src/main/java/io/github/benny123tw/servlet/annotation/EnableVite.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,16 @@ | ||
package io.github.benny123tw.servlet.annotation; | ||
|
||
import io.github.benny123tw.servlet.config.ViteConfig; | ||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
import org.springframework.context.annotation.Import; | ||
|
||
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
@Documented | ||
@Import(ViteConfig.class) | ||
public @interface EnableVite { | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
vite-spring-webmvc-jre8/src/main/java/io/github/benny123tw/servlet/config/ViteConfig.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,36 @@ | ||
package io.github.benny123tw.servlet.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.beans.factory.annotation.Value; | ||
|
||
/** | ||
* Provides an out-of-the-box configuration for Vite. | ||
*/ | ||
@Configuration | ||
@ComponentScan(basePackages = "io.github.benny123tw.servlet.config") | ||
public class ViteConfig { | ||
|
||
@Value("${vite.debug:true}") | ||
private boolean debug; | ||
|
||
@Value("${vite.manifestPath:/WEB-INF/dist/.vite/manifest.json}") | ||
private String manifestPath; | ||
|
||
@Value("${vite.localServerUrl:http://localhost:5173}") | ||
private String localServerUrl; | ||
|
||
@Value("${vite.resourcePath:/resources}") | ||
private String resourcePath; | ||
|
||
@Bean | ||
public ViteProperties viteProperties() { | ||
ViteProperties viteProperties = new ViteProperties(); | ||
viteProperties.setDebug(debug); | ||
viteProperties.setManifestPath(manifestPath); | ||
viteProperties.setLocalServerUrl(localServerUrl); | ||
viteProperties.setResourcePath(resourcePath); | ||
return viteProperties; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...-spring-webmvc-jre8/src/main/java/io/github/benny123tw/servlet/config/ViteProperties.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,62 @@ | ||
package io.github.benny123tw.servlet.config; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@ConfigurationProperties(prefix = "vite") | ||
public class ViteProperties { | ||
|
||
/** | ||
* Whether to enable debug mode in Vite. | ||
*/ | ||
private boolean debug = true; | ||
|
||
/** | ||
* The path of the manifest file generated by Vite. | ||
*/ | ||
private String manifestPath = "/WEB-INF/dist/.vite/manifest.json"; | ||
|
||
/** | ||
* The local server URL for Vite development. | ||
*/ | ||
private String localServerUrl = "http://localhost:5173"; | ||
|
||
/** | ||
* The path to the resources. | ||
*/ | ||
private String resourcePath = "/resources"; | ||
|
||
public boolean isDebug() { | ||
return debug; | ||
} | ||
|
||
public void setDebug(boolean debug) { | ||
this.debug = debug; | ||
} | ||
|
||
public String getManifestPath() { | ||
return manifestPath; | ||
} | ||
|
||
public void setManifestPath(String manifestPath) { | ||
this.manifestPath = manifestPath; | ||
} | ||
|
||
public String getLocalServerUrl() { | ||
return localServerUrl; | ||
} | ||
|
||
public void setLocalServerUrl(String localServerUrl) { | ||
this.localServerUrl = localServerUrl; | ||
} | ||
|
||
public String getResourcePath() { | ||
return resourcePath; | ||
} | ||
|
||
public void setResourcePath(String resourcePath) { | ||
this.resourcePath = resourcePath; | ||
} | ||
|
||
} |
Oops, something went wrong.