forked from loafle/openapi-generator-original
[cli] Add --global-property for -D replacement (#5687)
-D option has been deprecated as it was previously used to: * Pass "system properties" * Pass additional properties This was confusing because we already have --additional-properties and because Java System Properties are passed as -D before program arguments. Confusion around the -D option had existed for some time, but when we introduced the thread-safe GlobalSettings to avoid overwriting Java System Properties, we created a hard break from Java System Properties in the generator. This also disconnected the previous "system properties" from accepting additional properties. Once these newly deprecated methods are removed, we will have a clear separation of concerns between: * Java System Properties * Global generator properties (used as workflow context) * Additional properties (used as generator options) This commit marks multiple places for cleanup in 5.0. These will be breaking changes, and lower effort to break in 5.0 with deprecation warnings now rather than adding sibling properties throughout the code and potentially introducing logic errors.
This commit is contained in:
@@ -28,13 +28,14 @@ import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* Represents those settings applied to a generation workflow.
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class WorkflowSettings {
|
||||
|
||||
private static final AtomicLong lastWarning = new AtomicLong(0);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(WorkflowSettings.class);
|
||||
public static final String DEFAULT_OUTPUT_DIR = ".";
|
||||
public static final boolean DEFAULT_VERBOSE = false;
|
||||
@@ -77,7 +78,15 @@ public class WorkflowSettings {
|
||||
this.templateDir = builder.templateDir;
|
||||
this.templatingEngineName = builder.templatingEngineName;
|
||||
this.ignoreFileOverride = builder.ignoreFileOverride;
|
||||
// TODO: rename to globalProperties for 5.0
|
||||
this.systemProperties = ImmutableMap.copyOf(builder.systemProperties);
|
||||
if (this.systemProperties.size() > 0) {
|
||||
// write no more than every 5s. This is temporary until version 5.0 as once(Logger) is not accessible here.
|
||||
// thread contention may cause this to write more than once, but this is just an attempt to reduce noise
|
||||
if (System.currentTimeMillis() - lastWarning.getAndUpdate(x -> System.currentTimeMillis()) > 5000) {
|
||||
LOGGER.warn("systemProperties will be renamed to globalProperties in version 5.0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user