wip - fixing jar file

This commit is contained in:
Dario Ghunney Ware 2025-05-20 12:35:36 +01:00
parent 28f8f69bea
commit 9c7631f9f2
9 changed files with 120 additions and 80 deletions

View File

@ -4,7 +4,7 @@ Copyright (c) 2024 Stirling Tools
Portions of this software are licensed as follows: Portions of this software are licensed as follows:
* All content that resides under the "enterprise/" directory of this repository, if that directory exists, is licensed under the license defined in "enterprise/LICENSE". * All content that resides under the "proprietary/" directory of this repository, if that directory exists, is licensed under the license defined in "proprietary/LICENSE".
* Content outside of the above mentioned directories or restrictions above is available under the MIT License as defined below. * Content outside of the above mentioned directories or restrictions above is available under the MIT License as defined below.
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy

View File

@ -8,8 +8,9 @@ plugins {
id "com.diffplug.spotless" version "7.0.3" id "com.diffplug.spotless" version "7.0.3"
id "com.github.jk1.dependency-license-report" version "2.9" id "com.github.jk1.dependency-license-report" version "2.9"
//id "nebula.lint" version "19.0.3" //id "nebula.lint" version "19.0.3"
id("org.panteleyev.jpackageplugin") version "1.6.1" id "org.panteleyev.jpackageplugin" version "1.6.1"
id "org.sonarqube" version "6.1.0.5360" id "org.sonarqube" version "6.1.0.5360"
id "com.gradleup.shadow" version "8.3.6"
} }
import com.github.jk1.license.render.* import com.github.jk1.license.render.*
@ -29,7 +30,6 @@ ext {
tempJrePath = null tempJrePath = null
} }
// todo: package jar with option for enterprise features to be included
jar { jar {
enabled = false enabled = false
manifest { manifest {
@ -86,6 +86,7 @@ subprojects {
apply plugin: 'com.diffplug.spotless' apply plugin: 'com.diffplug.spotless'
apply plugin: 'org.springframework.boot' apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management' apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.gradleup.shadow'
java { java {
// 17 is lowest but we support and recommend 21 // 17 is lowest but we support and recommend 21

View File

@ -1,45 +0,0 @@
package stirling.software.common.configuration;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.EncodedResource;
@Slf4j
@Configuration
public class YamlConfig {
@Bean
public PropertySource<?> dynamicYamlPropertySource(ConfigurableEnvironment environment)
throws IOException {
String configPath = InstallationPathConfig.getSettingsPath();
log.debug("Attempting to load settings from: {}", configPath);
File file = new File(configPath);
if (!file.exists()) {
log.error("Warning: Settings file does not exist at: {}", configPath);
}
Resource resource = new FileSystemResource(configPath);
if (!resource.exists()) {
throw new FileNotFoundException("Settings file not found at: " + configPath);
}
EncodedResource encodedResource = new EncodedResource(resource);
PropertySource<?> propertySource =
new YamlPropertySourceFactory().createPropertySource(null, encodedResource);
environment.getPropertySources().addFirst(propertySource);
log.debug("Loaded properties: {}", propertySource.getSource());
return propertySource;
}
}

View File

@ -1,5 +1,7 @@
package stirling.software.common.model; package stirling.software.common.model;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
@ -14,26 +16,63 @@ import lombok.Data;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString; import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import stirling.software.common.configuration.InstallationPathConfig;
import stirling.software.common.configuration.YamlPropertySourceFactory;
import stirling.software.common.model.exception.UnsupportedProviderException; import stirling.software.common.model.exception.UnsupportedProviderException;
import stirling.software.common.util.ValidationUtil; import stirling.software.common.util.ValidationUtil;
import stirling.software.common.model.oauth2.provider.GitHubProvider; import stirling.software.common.model.oauth2.provider.GitHubProvider;
import stirling.software.common.model.oauth2.provider.GoogleProvider; import stirling.software.common.model.oauth2.provider.GoogleProvider;
import stirling.software.common.model.oauth2.provider.KeycloakProvider; import stirling.software.common.model.oauth2.provider.KeycloakProvider;
import stirling.software.common.model.oauth2.provider.Provider; import stirling.software.common.model.oauth2.provider.Provider;
import static stirling.software.common.util.ValidationUtil.isCollectionEmpty;
import static stirling.software.common.util.ValidationUtil.isStringEmpty;
@Data @Configuration
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
@ConfigurationProperties(prefix = "") @ConfigurationProperties(prefix = "")
@Data
@Order(Ordered.HIGHEST_PRECEDENCE)
@Slf4j
public class ApplicationProperties { public class ApplicationProperties {
@Bean
public PropertySource<?> dynamicYamlPropertySource(ConfigurableEnvironment environment)
throws IOException {
String configPath = InstallationPathConfig.getSettingsPath();
log.info("Attempting to load settings from: " + configPath);
File file = new File(configPath);
if (!file.exists()) {
log.error("Warning: Settings file does not exist at: " + configPath);
}
Resource resource = new FileSystemResource(configPath);
if (!resource.exists()) {
throw new FileNotFoundException("Settings file not found at: " + configPath);
}
EncodedResource encodedResource = new EncodedResource(resource);
PropertySource<?> propertySource =
new YamlPropertySourceFactory().createPropertySource(null, encodedResource);
environment.getPropertySources().addFirst(propertySource);
log.info("Loaded properties: " + propertySource.getSource());
return propertySource;
}
private Legal legal = new Legal(); private Legal legal = new Legal();
private Security security = new Security(); private Security security = new Security();
private System system = new System(); private System system = new System();
@ -208,11 +247,11 @@ public class ApplicationProperties {
} }
public boolean isSettingsValid() { public boolean isSettingsValid() {
return !ValidationUtil.isStringEmpty(this.getIssuer()) return !isStringEmpty(this.getIssuer())
&& !ValidationUtil.isStringEmpty(this.getClientId()) && !isStringEmpty(this.getClientId())
&& !ValidationUtil.isStringEmpty(this.getClientSecret()) && !isStringEmpty(this.getClientSecret())
&& !ValidationUtil.isCollectionEmpty(this.getScopes()) && !isCollectionEmpty(this.getScopes())
&& !ValidationUtil.isStringEmpty(this.getUseAsUsername()); && !isStringEmpty(this.getUseAsUsername());
} }
@Data @Data

View File

@ -68,5 +68,48 @@ dependencies {
// runtimeOnly "com.twelvemonkeys.imageio:imageio-thumbsdb:$imageioVersion" // runtimeOnly "com.twelvemonkeys.imageio:imageio-thumbsdb:$imageioVersion"
// runtimeOnly "com.twelvemonkeys.imageio:imageio-xwd:$imageioVersion" // runtimeOnly "com.twelvemonkeys.imageio:imageio-xwd:$imageioVersion"
developmentOnly "org.springframework.boot:spring-boot-devtools:$springBootVersion" developmentOnly 'org.springframework.boot:spring-boot-devtools'
} }
sourceSets {
main {
resources {
srcDirs += ['../configs']
}
}
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest {
attributes(
'Main-Class': 'stirling.software.spdf.SPDFApplication',
"Implementation-Title": "Stirling-PDF",
"Implementation-Version": project.version
)
}
}
shadowJar {
archiveClassifier.set('shadow')
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes(
'Main-Class': 'stirling.software.spdf.SPDFApplication'
)
}
zip64 = true
mergeServiceFiles()
}
build.dependsOn shadowJar
jar.dependsOn ':common:jar'
shadowJar.dependsOn ':common:jar'
jar.dependsOn ':proprietary:jar'
shadowJar.dependsOn ':proprietary:jar'

View File

@ -17,6 +17,7 @@ server.error.include-message=always
#logging.level.org.springframework.web=DEBUG #logging.level.org.springframework.web=DEBUG
#logging.level.org.springframework=DEBUG #logging.level.org.springframework=DEBUG
#logging.level.org.springframework.security=DEBUG #logging.level.org.springframework.security=DEBUG
spring.servlet.multipart.max-file-size=2000MB spring.servlet.multipart.max-file-size=2000MB
spring.servlet.multipart.max-request-size=2000MB spring.servlet.multipart.max-request-size=2000MB
server.servlet.session.tracking-modes=cookie server.servlet.session.tracking-modes=cookie
@ -29,6 +30,8 @@ spring.web.resources.mime-mappings.webmanifest=application/manifest+json
spring.mvc.async.request-timeout=${SYSTEM_CONNECTIONTIMEOUTMILLISECONDS:1200000} spring.mvc.async.request-timeout=${SYSTEM_CONNECTIONTIMEOUTMILLISECONDS:1200000}
management.endpoints.web.exposure.include=beans management.endpoints.web.exposure.include=beans
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
#spring.config.additional-location=classpath:configs/settings.yml
spring.datasource.url=jdbc:h2:file:./configs/stirling-pdf-DB-2.3.232;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=PostgreSQL spring.datasource.url=jdbc:h2:file:./configs/stirling-pdf-DB-2.3.232;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=PostgreSQL
spring.datasource.driver-class-name=org.h2.Driver spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=sa spring.datasource.username=sa

View File

@ -40,10 +40,6 @@ import stirling.software.common.util.UrlUtils;
"stirling.software.common", "stirling.software.common",
"stirling.software.proprietary", "stirling.software.proprietary",
"stirling.software.proprietary.configuration" "stirling.software.proprietary.configuration"
},
exclude = {
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class
}) })
public class SPDFApplication { public class SPDFApplication {

View File

@ -17,6 +17,7 @@ server.error.include-message=always
#logging.level.org.springframework.web=DEBUG #logging.level.org.springframework.web=DEBUG
#logging.level.org.springframework=DEBUG #logging.level.org.springframework=DEBUG
#logging.level.org.springframework.security=DEBUG #logging.level.org.springframework.security=DEBUG
spring.servlet.multipart.max-file-size=2000MB spring.servlet.multipart.max-file-size=2000MB
spring.servlet.multipart.max-request-size=2000MB spring.servlet.multipart.max-request-size=2000MB
server.servlet.session.tracking-modes=cookie server.servlet.session.tracking-modes=cookie
@ -29,6 +30,8 @@ spring.web.resources.mime-mappings.webmanifest=application/manifest+json
spring.mvc.async.request-timeout=${SYSTEM_CONNECTIONTIMEOUTMILLISECONDS:1200000} spring.mvc.async.request-timeout=${SYSTEM_CONNECTIONTIMEOUTMILLISECONDS:1200000}
management.endpoints.web.exposure.include=beans management.endpoints.web.exposure.include=beans
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
#spring.config.additional-location=classpath:configs/settings.yml
spring.datasource.url=jdbc:h2:file:./configs/stirling-pdf-DB-2.3.232;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=PostgreSQL spring.datasource.url=jdbc:h2:file:./configs/stirling-pdf-DB-2.3.232;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=PostgreSQL
spring.datasource.driver-class-name=org.h2.Driver spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=sa spring.datasource.username=sa