Class AbstractPlatformModelMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
ai.timefold.solver.tools.maven.AbstractPlatformModelMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
ConfigureMojo, DeployModelMojo, PermissionsMojo, UndeployModelMojo
public abstract class AbstractPlatformModelMojo
extends org.apache.maven.plugin.AbstractMojo
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringURL to the platform that model should be deployed toprotected booleanDetermines if the model registration should automatically subscribe/unsubscribe to the registered modelprotected HttpClientprotected StringUnique key used to register model with - used also when unregisteringprotected com.fasterxml.jackson.databind.ObjectMapperprotected StringURL to the platform that model should be deployed tostatic final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected StringId of the<server>entry in the Maven settings that holds the personal access token, as an alternative to exporting it asTIMEFOLD_PATprotected org.apache.maven.execution.MavenSessionFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigureHttpRequest(HttpRequest.Builder builder) protected PlatformIdentityInfofetchPlatformIdentityInfo(boolean includeConfig) protected AccessTokenProviderprotected StringResolves the configured platform URL, stripping any trailing slashes so it can be safely concatenated with a path that starts with a slash (e.g.protected <T> TgetPropertyOrParameter(String propertyName, T parameter) protected voidprintErrorInfo(String responseBody) protected StringreadErrorField(String responseBody, String fieldName) protected StringreadErrorMessage(String responseBody) Reads the platform error message from an error response body, so that the reason for the failure is part of the reported error and not only of the build log.protected com.fasterxml.jackson.databind.node.ObjectNodereadModelDescriptor(Path modelDescriptorArchivePath) protected StringResolves the personal access token, failing the build when none is configured.protected voidsetAccessTokenProvider(AccessTokenProvider provider) protected voidvalidate()Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContextMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.maven.plugin.Mojo
execute
-
Field Details
-
PROP_DRY_RUN
- See Also:
-
PROP_PLATFORM_URL
- See Also:
-
PROP_MODEL_KEY
- See Also:
-
PROP_MODEL_TENANTS
- See Also:
-
PROP_MODEL_SUBS
- See Also:
-
PROP_SERVER_ID
- See Also:
-
session
@Parameter(defaultValue="${session}", readonly=true) protected org.apache.maven.execution.MavenSession session -
serverId
@Parameter(property="timefold.serverId", required=false, defaultValue="timefold-platform") protected String serverIdId of the<server>entry in the Maven settings that holds the personal access token, as an alternative to exporting it asTIMEFOLD_PAT -
buildDirectory
@Parameter(defaultValue="${project.build.directory}", required=false) protected String buildDirectoryURL to the platform that model should be deployed to -
platformUrl
URL to the platform that model should be deployed to -
key
Unique key used to register model with - used also when unregistering -
handleSubscription
@Parameter(property="timefold.model.handleSubscription", required=false, defaultValue="false") protected boolean handleSubscriptionDetermines if the model registration should automatically subscribe/unsubscribe to the registered model -
mapper
protected com.fasterxml.jackson.databind.ObjectMapper mapper -
httpClient
-
-
Constructor Details
-
AbstractPlatformModelMojo
public AbstractPlatformModelMojo()
-
-
Method Details
-
getAccessTokenProvider
-
setAccessTokenProvider
-
fetchPlatformIdentityInfo
protected PlatformIdentityInfo fetchPlatformIdentityInfo(boolean includeConfig) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
requireAccessToken
Resolves the personal access token, failing the build when none is configured. Without this the request goes out with an empty bearer token and the platform answers with an authentication error, which points at the token being wrong rather than at it never having been configured.Deliberately called while a request is built rather than up front, so that the goals which send nothing on a dry run still run without a token:
deployandundeployonly reach here once they have decided to actually call the platform.configurereads the platform configuration even on a dry run, as it has to write the registry and account id it would build with, so that goal needs a token either way.- Throws:
org.apache.maven.plugin.MojoExecutionException- when no token is configured, or when the configured one cannot be read
-
configureHttpRequest
protected void configureHttpRequest(HttpRequest.Builder builder) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
validate
protected void validate() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException- when a mandatory parameter is not configured; a missing parameter is a build configuration problem, so it has to be reported as one rather than as an internal error
-
printErrorInfo
-
readErrorMessage
Reads the platform error message from an error response body, so that the reason for the failure is part of the reported error and not only of the build log. Falls back to the response body itself, as the platform does not report every error as anErrorInfo. -
readErrorField
-
getPlatformUrl
Resolves the configured platform URL, stripping any trailing slashes so it can be safely concatenated with a path that starts with a slash (e.g. "/api/platform/v1/...").- Throws:
org.apache.maven.plugin.MojoExecutionException- when no platform URL is configured, which no goal can work without
-
readModelDescriptor
protected com.fasterxml.jackson.databind.node.ObjectNode readModelDescriptor(Path modelDescriptorArchivePath) throws IOException - Throws:
IOException
-
getPropertyOrParameter
-
getTenants
-