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 Details

    • PROP_DRY_RUN

      public static final String PROP_DRY_RUN
      See Also:
    • PROP_PLATFORM_URL

      protected static final String PROP_PLATFORM_URL
      See Also:
    • PROP_MODEL_KEY

      protected static final String PROP_MODEL_KEY
      See Also:
    • PROP_MODEL_TENANTS

      protected static final String PROP_MODEL_TENANTS
      See Also:
    • PROP_MODEL_SUBS

      protected static final String PROP_MODEL_SUBS
      See Also:
    • PROP_SERVER_ID

      protected static final String 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 serverId
      Id of the <server> entry in the Maven settings that holds the personal access token, as an alternative to exporting it as TIMEFOLD_PAT
    • buildDirectory

      @Parameter(defaultValue="${project.build.directory}", required=false) protected String buildDirectory
      URL to the platform that model should be deployed to
    • platformUrl

      @Parameter(property="timefold.platformUrl", required=true) protected String platformUrl
      URL to the platform that model should be deployed to
    • key

      @Parameter(property="timefold.model.key", required=true) protected String key
      Unique key used to register model with - used also when unregistering
    • handleSubscription

      @Parameter(property="timefold.model.handleSubscription", required=false, defaultValue="false") protected boolean handleSubscription
      Determines if the model registration should automatically subscribe/unsubscribe to the registered model
    • mapper

      protected com.fasterxml.jackson.databind.ObjectMapper mapper
    • httpClient

      protected HttpClient httpClient
  • Constructor Details

    • AbstractPlatformModelMojo

      public AbstractPlatformModelMojo()
  • Method Details

    • getAccessTokenProvider

      protected AccessTokenProvider getAccessTokenProvider()
    • setAccessTokenProvider

      protected void setAccessTokenProvider(AccessTokenProvider provider)
    • fetchPlatformIdentityInfo

      protected PlatformIdentityInfo fetchPlatformIdentityInfo(boolean includeConfig) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • requireAccessToken

      protected String requireAccessToken() throws org.apache.maven.plugin.MojoExecutionException
      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: deploy and undeploy only reach here once they have decided to actually call the platform. configure reads 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

      protected void printErrorInfo(String responseBody)
    • readErrorMessage

      protected String readErrorMessage(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. Falls back to the response body itself, as the platform does not report every error as an ErrorInfo.
    • readErrorField

      protected String readErrorField(String responseBody, String fieldName)
    • getPlatformUrl

      protected String getPlatformUrl() throws org.apache.maven.plugin.MojoExecutionException
      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

      protected <T> T getPropertyOrParameter(String propertyName, T parameter)
    • getTenants

      public List<String> getTenants()