diff --git a/gradle.properties b/gradle.properties index 33aa3f7..dfe35db 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=0.1.2 +version=0.1.3-alpha diff --git a/javite-webmvc-jre8/src/main/java/com/javite/spring/config/ViteConfig.java b/javite-webmvc-jre8/src/main/java/com/javite/spring/config/ViteConfig.java index 3ab71a0..b703872 100644 --- a/javite-webmvc-jre8/src/main/java/com/javite/spring/config/ViteConfig.java +++ b/javite-webmvc-jre8/src/main/java/com/javite/spring/config/ViteConfig.java @@ -1,8 +1,8 @@ package com.javite.spring.config; -import com.javite.config.ViteProperties; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; /** @@ -31,6 +31,7 @@ * @see com.javite.spring.annotation.EnableVite */ @Configuration +@ComponentScan(basePackages = "com.javite.spring.config") public class ViteConfig { @Value("${vite.debug:true}") diff --git a/javite-webmvc-jre8/src/main/java/com/javite/spring/config/ViteProperties.java b/javite-webmvc-jre8/src/main/java/com/javite/spring/config/ViteProperties.java new file mode 100644 index 0000000..f898fb1 --- /dev/null +++ b/javite-webmvc-jre8/src/main/java/com/javite/spring/config/ViteProperties.java @@ -0,0 +1,124 @@ +package com.javite.spring.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * Configuration properties for integrating Vite with Java web applications. + * + *

This class provides properties that can be used to configure the Vite integration, + * including settings for the Vite manifest file, local development server URL, resource paths, and debug mode.

+ * + *

These properties can be configured in the application's configuration file (e.g., `application.properties` + * or `application.yml` for Spring applications) and are typically used by integration modules to facilitate the setup and use of Vite in Java web + * applications.

+ * + *

Usage example:

+ *
+ * vite.debug=true
+ * vite.manifestPath=/WEB-INF/dist/.vite/manifest.json
+ * vite.localServerUrl=http://localhost:5173
+ * vite.resourcePath=/resources
+ * 
+ */ +@Component +@ConfigurationProperties(prefix = "vite") +public class ViteProperties { + + /** + * Whether to enable debug mode in Vite. + *

Default is {@code true}.

+ */ + private boolean debug = true; + + /** + * The path of the manifest file generated by Vite. + *

Default is {@code /WEB-INF/dist/.vite/manifest.json}.

+ */ + private String manifestPath = "/WEB-INF/dist/.vite/manifest.json"; + + /** + * The local server URL for Vite development. + *

Default is {@code http://localhost:5173}.

+ */ + private String localServerUrl = "http://localhost:5173"; + + /** + * The path to the resources. + *

Default is {@code /resources}.

+ */ + private String resourcePath = "/resources"; + + /** + * Returns whether debug mode is enabled. + * + * @return {@code true} if debug mode is enabled, {@code false} otherwise + */ + public boolean isDebug() { + return debug; + } + + /** + * Sets whether debug mode is enabled. + * + * @param debug {@code true} to enable debug mode, {@code false} to disable it + */ + public void setDebug(boolean debug) { + this.debug = debug; + } + + /** + * Returns the path of the manifest file generated by Vite. + * + * @return the manifest file path + */ + public String getManifestPath() { + return manifestPath; + } + + /** + * Sets the path of the manifest file generated by Vite. + * + * @param manifestPath the manifest file path + */ + public void setManifestPath(String manifestPath) { + this.manifestPath = manifestPath; + } + + /** + * Returns the local server URL for Vite development. + * + * @return the local server URL + */ + public String getLocalServerUrl() { + return localServerUrl; + } + + /** + * Sets the local server URL for Vite development. + * + * @param localServerUrl the local server URL + */ + public void setLocalServerUrl(String localServerUrl) { + this.localServerUrl = localServerUrl; + } + + /** + * Returns the path to the resources. + * + * @return the resource path + */ + public String getResourcePath() { + return resourcePath; + } + + /** + * Sets the path to the resources. + * + * @param resourcePath the resource path + */ + public void setResourcePath(String resourcePath) { + this.resourcePath = resourcePath; + } + +} diff --git a/javite-webmvc-jre8/src/main/resources/META-INF/vite.tld b/javite-webmvc-jre8/src/main/resources/META-INF/vite.tld index 96d6063..733f819 100644 --- a/javite-webmvc-jre8/src/main/resources/META-INF/vite.tld +++ b/javite-webmvc-jre8/src/main/resources/META-INF/vite.tld @@ -7,6 +7,10 @@ Vite JSP Tag Library vite + Import a Vite asset. + import + com.javite.spring.tags.ViteImport + empty The entry point of the Vite asset to be imported. entry @@ -37,10 +41,6 @@ false true - empty - Import a Vite asset. - import - com.javite.spring.tags.ViteImport 1.0 diff --git a/javite-webmvc/src/main/java/com/javite/spring/config/ViteConfig.java b/javite-webmvc/src/main/java/com/javite/spring/config/ViteConfig.java index 8f301af..bcb033b 100644 --- a/javite-webmvc/src/main/java/com/javite/spring/config/ViteConfig.java +++ b/javite-webmvc/src/main/java/com/javite/spring/config/ViteConfig.java @@ -1,9 +1,10 @@ package com.javite.spring.config; +import com.javite.config.ViteProperties; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import com.javite.config.ViteProperties; /** * Configuration class for integrating Vite with Spring MVC applications. @@ -12,6 +13,7 @@ * {@code application.properties} file.

*/ @Configuration +@EnableConfigurationProperties(ViteProperties.class) public class ViteConfig { @Value("${vite.debug:true}") diff --git a/javite-webmvc/src/main/java/com/javite/spring/config/ViteProperties.java b/javite-webmvc/src/main/java/com/javite/spring/config/ViteProperties.java new file mode 100644 index 0000000..f898fb1 --- /dev/null +++ b/javite-webmvc/src/main/java/com/javite/spring/config/ViteProperties.java @@ -0,0 +1,124 @@ +package com.javite.spring.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * Configuration properties for integrating Vite with Java web applications. + * + *

This class provides properties that can be used to configure the Vite integration, + * including settings for the Vite manifest file, local development server URL, resource paths, and debug mode.

+ * + *

These properties can be configured in the application's configuration file (e.g., `application.properties` + * or `application.yml` for Spring applications) and are typically used by integration modules to facilitate the setup and use of Vite in Java web + * applications.

+ * + *

Usage example:

+ *
+ * vite.debug=true
+ * vite.manifestPath=/WEB-INF/dist/.vite/manifest.json
+ * vite.localServerUrl=http://localhost:5173
+ * vite.resourcePath=/resources
+ * 
+ */ +@Component +@ConfigurationProperties(prefix = "vite") +public class ViteProperties { + + /** + * Whether to enable debug mode in Vite. + *

Default is {@code true}.

+ */ + private boolean debug = true; + + /** + * The path of the manifest file generated by Vite. + *

Default is {@code /WEB-INF/dist/.vite/manifest.json}.

+ */ + private String manifestPath = "/WEB-INF/dist/.vite/manifest.json"; + + /** + * The local server URL for Vite development. + *

Default is {@code http://localhost:5173}.

+ */ + private String localServerUrl = "http://localhost:5173"; + + /** + * The path to the resources. + *

Default is {@code /resources}.

+ */ + private String resourcePath = "/resources"; + + /** + * Returns whether debug mode is enabled. + * + * @return {@code true} if debug mode is enabled, {@code false} otherwise + */ + public boolean isDebug() { + return debug; + } + + /** + * Sets whether debug mode is enabled. + * + * @param debug {@code true} to enable debug mode, {@code false} to disable it + */ + public void setDebug(boolean debug) { + this.debug = debug; + } + + /** + * Returns the path of the manifest file generated by Vite. + * + * @return the manifest file path + */ + public String getManifestPath() { + return manifestPath; + } + + /** + * Sets the path of the manifest file generated by Vite. + * + * @param manifestPath the manifest file path + */ + public void setManifestPath(String manifestPath) { + this.manifestPath = manifestPath; + } + + /** + * Returns the local server URL for Vite development. + * + * @return the local server URL + */ + public String getLocalServerUrl() { + return localServerUrl; + } + + /** + * Sets the local server URL for Vite development. + * + * @param localServerUrl the local server URL + */ + public void setLocalServerUrl(String localServerUrl) { + this.localServerUrl = localServerUrl; + } + + /** + * Returns the path to the resources. + * + * @return the resource path + */ + public String getResourcePath() { + return resourcePath; + } + + /** + * Sets the path to the resources. + * + * @param resourcePath the resource path + */ + public void setResourcePath(String resourcePath) { + this.resourcePath = resourcePath; + } + +} diff --git a/javite-webmvc/src/main/resources/META-INF/vite.tld b/javite-webmvc/src/main/resources/META-INF/vite.tld index 941c56e..f134019 100644 --- a/javite-webmvc/src/main/resources/META-INF/vite.tld +++ b/javite-webmvc/src/main/resources/META-INF/vite.tld @@ -7,7 +7,7 @@ Vite JSP Tag Library 1.0 vite - https://javite.com + https://javite.com/tags Import a Vite asset.