Skip to content

Commit

Permalink
chore: add support for authenticated Enterprise repo (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
triceo authored Apr 25, 2024
1 parent d5f1d06 commit 93f5b58
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ai.timefold.solver.core.enterprise;

import java.lang.reflect.InvocationTargetException;
import java.util.Objects;
import java.util.function.BiFunction;

import ai.timefold.solver.core.api.score.stream.ConstraintProvider;
Expand Down Expand Up @@ -33,16 +34,28 @@

public interface TimefoldSolverEnterpriseService {

String SOLVER_NAME = "Timefold Solver";
String COMMUNITY_NAME = "Community Edition";
String COMMUNITY_COORDINATES = "ai.timefold.solver:timefold-solver-core";
String ENTERPRISE_NAME = "Enterprise Edition";
String ENTERPRISE_COORDINATES = "ai.timefold.solver.enterprise:timefold-solver-enterprise-core";
String DEVELOPMENT_SNAPSHOT = "Development Snapshot";

static String identifySolverVersion() {
var packaging = "Community Edition";
var packaging = COMMUNITY_NAME;
try {
TimefoldSolverEnterpriseService.load();
packaging = "Enterprise Edition";
load();
packaging = ENTERPRISE_NAME;
} catch (Exception e) {
// No need to do anything, just checking if Enterprise exists.
}
var version = SolverFactory.class.getPackage().getImplementationVersion();
return packaging + " " + (version == null ? "(Development snapshot)" : "v" + version);
var version = getVersionString(SolverFactory.class);
return packaging + " " + version;
}

private static String getVersionString(Class<?> clz) {
var version = clz.getPackage().getImplementationVersion();
return (version == null ? DEVELOPMENT_SNAPSHOT : "v" + version);
}

static TimefoldSolverEnterpriseService load() throws ClassNotFoundException, NoSuchMethodException,
Expand All @@ -54,16 +67,30 @@ static TimefoldSolverEnterpriseService load() throws ClassNotFoundException, NoS
}

static TimefoldSolverEnterpriseService loadOrFail(Feature feature) {
TimefoldSolverEnterpriseService service;
try {
return load();
service = load();
} catch (Exception cause) {
throw new IllegalStateException("""
%s requested but Timefold Solver Enterprise Edition not found on classpath
Either add the ai.timefold.solver.enterprise:timefold-solver-enterprise-core dependency,
or %s.
"Note: Timefold Solver Enterprise Edition is a commercial product."""
.formatted(feature.getName(), feature.getWorkaround()), cause);
%s requested but %s %s not found on classpath.
Either add the %s dependency, or %s.
Note: %s %s is a commercial product. Visit https://timefold.ai to find out more."""
.formatted(feature.getName(), SOLVER_NAME, ENTERPRISE_NAME, feature.getWorkaround(),
ENTERPRISE_COORDINATES, SOLVER_NAME, ENTERPRISE_NAME),
cause);
}
var communityVersion = getVersionString(TimefoldSolverEnterpriseService.class);
var enterpriseVersion = getVersionString(service.getClass());
if (Objects.equals(communityVersion, enterpriseVersion)) { // Identical versions.
return service;
} else if (enterpriseVersion.equals(DEVELOPMENT_SNAPSHOT)) { // Don't enforce when running Enterprise tests.
return service;
}
throw new IllegalStateException("""
Detected mismatch between versions of %s %s (%s) and %s (%s).
Ensure your project uses the same version of %s and %s dependencies."""
.formatted(SOLVER_NAME, COMMUNITY_NAME, communityVersion, ENTERPRISE_NAME, enterpriseVersion,
COMMUNITY_COORDINATES, ENTERPRISE_COORDINATES));
}

Class<? extends ConstraintProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@

Timefold Solver Enterprise Edition is a commercial product that offers additional features,
such as <<nearbySelection,nearby selection>> and <<multithreadedSolving,multi-threaded solving>>.
These features are essential to scale out to very large datasets.
These features are essential to scale out to huge datasets.

Unlike Timefold Solver Community Edition, the Enterprise Edition is not open-source.
You are allowed to use Timefold Solver Enterprise Edition for evaluation and development.
Please contact https://timefold.ai/contact[contact Timefold]
to obtain the credentials necessary to start your evaluation.

You are allowed to use Timefold Solver Enterprise Edition for evaluation and development,
but to use it in production,
you are required to https://timefold.ai/company/contact/[purchase a license].
For a high-level overview of the differences between Timefold offerings,
see https://timefold.ai/pricing[Timefold Pricing].

Unlike Timefold Solver Community Edition,
the Enterprise Edition is not open-source.


[#switchToEnterpriseEdition]
== Switch to Enterprise Edition

In order to switch from Timefold Solver Community Edition to Enterprise Edition,
first reference the Enterprise Edition Maven repository in your project.
To switch from Timefold Solver Community Edition to Enterprise Edition,
first reference the Enterprise Edition Maven repository in your project:

[tabs]
====
Expand All @@ -44,6 +43,26 @@ Add the following repository to your `pom.xml`:
...
</project>
----
Then create `.m2/settings.xml` in your home directory with the following content:
[source,xml,options="nowrap"]
----
<settings>
...
<servers>
<server>
<!-- Replace "my_username" and "my_password" with credentials obtained from a Timefold representative. -->
<id>timefold-solver-enterprise</id>
<username>my_username</username>
<password>my_password</password>
</server>
</servers>
...
</settings>
----
See https://maven.apache.org/settings.html[Settings Reference] for more information on Maven settings.
--
Gradle::
+
Expand All @@ -56,14 +75,21 @@ repositories {
mavenCentral()
maven {
url "https://timefold.jfrog.io/artifactory/releases/"
credentials { // Replace "my_username" and "my_password" with credentials obtained from a Timefold representative.
username "my_username"
password "my_password"
}
authentication {
basic(BasicAuthentication)
}
}
}
----
--
====

Having done that the above, replace references to Community Edition artifacts by their Enterprise Edition counterparts
as shown in the table below.
Having done the above, replace references to Community Edition artifacts by their Enterprise Edition counterparts
as shown in the following table:

|===
|Community Edition|Enterprise Edition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,27 @@ Every upgrade note indicates how likely your code will be affected by that chang
- icon:eye[] *Recommended*: Does not affect backwards compatibility, but you probably want to be aware.
The upgrade recipe often lists the changes as they apply to Java code.
Kotlin users should translate the changes accordingly.
We kindly ask Kotlin and Python users to translate the changes accordingly.

=== Upgrade from 1.9.0 to 1.10.0

.icon:eye[] Enterprise Edition Maven Repository will soon require authentication
[%collapsible%open]
====
Timefold customers newly need to authenticate to access the Enterprise Edition Maven Repository.
If you are a Timefold customer, you should have received your credentials from Timefold by now.
If you haven't, we kindly ask that you https://timefold.ai/contact[contact us].
If you are not a Timefold customer and you wish to retain your access to the Enterprise Edition Maven Repository,
you can https://timefold.ai/contact[contact us] to start your evaluation.
There are https://timefold.ai/pricing[many benefits] to being a Timefold customer.
For more information on setting up the Enterprise Edition Maven Repository,
see xref:enterprise-edition/enterprise-edition.adoc#switchToEnterpriseEdition[the Enterprise Edition documentation].
====

'''

.icon:info-circle[role=yellow] `LookupStrategyType` deprecated for removal
[%collapsible%open]
====
Expand Down

0 comments on commit 93f5b58

Please sign in to comment.