This commit is contained in:
Anthony Stirling 2025-06-10 00:59:58 +01:00
parent 716a9098d2
commit 502a67f0ae
5 changed files with 54 additions and 27 deletions

View File

@ -567,10 +567,10 @@ tasks.named('bootRun') {
tasks.named('build') { tasks.named('build') {
group = 'build' group = 'build'
description = 'Delegates to :stirling-pdf:build' description = 'Delegates to :stirling-pdf:bootJar'
dependsOn ':stirling-pdf:build' dependsOn ':stirling-pdf:bootJar'
doFirst { doFirst {
println "Delegating to :stirling-pdf:build" println "Delegating to :stirling-pdf:bootJar"
} }
} }

View File

@ -20,6 +20,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@ -258,22 +259,25 @@ public class AppConfig {
@Bean(name = "runningProOrHigher") @Bean(name = "runningProOrHigher")
@ConditionalOnMissingBean(name = "runningProOrHigher") @Profile("default")
public boolean runningProOrHigher() { public boolean runningProOrHigher() {
return false; return false;
} }
@Bean(name = "runningEE") @Bean(name = "runningEE")
@Profile("default")
public boolean runningEnterprise() { public boolean runningEnterprise() {
return false; return false;
} }
@Bean(name = "GoogleDriveEnabled") @Bean(name = "GoogleDriveEnabled")
@Profile("default")
public boolean googleDriveEnabled() { public boolean googleDriveEnabled() {
return false; return false;
} }
@Bean(name = "license") @Bean(name = "license")
@Profile("default")
public String licenseType() { public String licenseType() {
return "NORMAL"; return "NORMAL";
} }

View File

@ -5,6 +5,7 @@ import static stirling.software.proprietary.security.configuration.ee.KeygenLice
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
@ -28,18 +29,21 @@ public class EEAppConfig {
migrateEnterpriseSettingsToPremium(this.applicationProperties); migrateEnterpriseSettingsToPremium(this.applicationProperties);
} }
@Profile("security")
@Bean(name = "runningProOrHigher") @Bean(name = "runningProOrHigher")
@Primary @Primary
public boolean runningProOrHigher() { public boolean runningProOrHigher() {
return licenseKeyChecker.getPremiumLicenseEnabledResult() != License.NORMAL; return licenseKeyChecker.getPremiumLicenseEnabledResult() != License.NORMAL;
} }
@Profile("security")
@Bean(name = "license") @Bean(name = "license")
@Primary @Primary
public String licenseType() { public String licenseType() {
return licenseKeyChecker.getPremiumLicenseEnabledResult().name(); return licenseKeyChecker.getPremiumLicenseEnabledResult().name();
} }
@Profile("security")
@Bean(name = "runningEE") @Bean(name = "runningEE")
@Primary @Primary
public boolean runningEnterprise() { public boolean runningEnterprise() {
@ -51,6 +55,7 @@ public class EEAppConfig {
return applicationProperties.getPremium().getProFeatures().isSsoAutoLogin(); return applicationProperties.getPremium().getProFeatures().isSsoAutoLogin();
} }
@Profile("security")
@Bean(name = "GoogleDriveEnabled") @Bean(name = "GoogleDriveEnabled")
@Primary @Primary
public boolean googleDriveEnabled() { public boolean googleDriveEnabled() {

View File

@ -103,16 +103,22 @@ sourceSets {
} }
// Configure regular jar (remove -plain classifier) // Disable regular jar
jar { jar {
archiveClassifier.set("") // Remove the -plain classifier enabled = false
}
// Configure and enable bootJar for this project
bootJar {
enabled = true
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
zip64 = true zip64 = true
from { // Don't include all dependencies directly like the old jar task did
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } // from {
} // configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
// }
// Exclude signature files to prevent "Invalid signature file digest" errors // Exclude signature files to prevent "Invalid signature file digest" errors
exclude 'META-INF/*.SF' exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA' exclude 'META-INF/*.DSA'
@ -121,17 +127,11 @@ jar {
manifest { manifest {
attributes( attributes(
'Main-Class': 'stirling.software.SPDF.SPDFApplication',
'Implementation-Title': 'Stirling-PDF', 'Implementation-Title': 'Stirling-PDF',
'Implementation-Version': project.version 'Implementation-Version': project.version
) )
} }
} }
// Enable bootJar for this project bootJar.dependsOn ':common:jar'
bootJar { bootJar.dependsOn ':proprietary:jar'
enabled = true
}
jar.dependsOn ':common:jar'
jar.dependsOn ':proprietary:jar'

View File

@ -204,17 +204,35 @@ public class SPDFApplication {
} }
private static String[] getActiveProfile(String[] args) { private static String[] getActiveProfile(String[] args) {
if (args == null) { // 1. Check for explicitly passed profiles
return new String[] {"default"}; if (args != null) {
} for (String arg : args) {
if (arg.startsWith("--spring.profiles.active=")) {
for (String arg : args) { String[] provided = arg.substring(arg.indexOf('=') + 1).split(",");
if (arg.contains("spring.profiles.active")) { if (provided.length > 0) {
return arg.substring(args[0].indexOf('=') + 1).split(", "); log.info("#######0000000000000###############################");
return provided;
}
}
} }
} }
log.info("######################################");
return new String[] {"default"}; // 2. Detect if SecurityConfiguration is present on classpath
if (isClassPresent("stirling.software.proprietary.security.configuration.SecurityConfiguration")) {
log.info("security");
return new String[] { "security" };
} else {
log.info("default");
return new String[] { "default" };
}
}
private static boolean isClassPresent(String className) {
try {
Class.forName(className, false, SPDFApplication.class.getClassLoader());
return true;
} catch (ClassNotFoundException e) {
return false;
}
} }
public static String getStaticBaseUrl() { public static String getStaticBaseUrl() {