Skip to content

Commit 93f5b58

Browse files
authored
chore: add support for authenticated Enterprise repo (#811)
1 parent d5f1d06 commit 93f5b58

File tree

3 files changed

+93
-23
lines changed

3 files changed

+93
-23
lines changed

core/src/main/java/ai/timefold/solver/core/enterprise/TimefoldSolverEnterpriseService.java

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ai.timefold.solver.core.enterprise;
22

33
import java.lang.reflect.InvocationTargetException;
4+
import java.util.Objects;
45
import java.util.function.BiFunction;
56

67
import ai.timefold.solver.core.api.score.stream.ConstraintProvider;
@@ -33,16 +34,28 @@
3334

3435
public interface TimefoldSolverEnterpriseService {
3536

37+
String SOLVER_NAME = "Timefold Solver";
38+
String COMMUNITY_NAME = "Community Edition";
39+
String COMMUNITY_COORDINATES = "ai.timefold.solver:timefold-solver-core";
40+
String ENTERPRISE_NAME = "Enterprise Edition";
41+
String ENTERPRISE_COORDINATES = "ai.timefold.solver.enterprise:timefold-solver-enterprise-core";
42+
String DEVELOPMENT_SNAPSHOT = "Development Snapshot";
43+
3644
static String identifySolverVersion() {
37-
var packaging = "Community Edition";
45+
var packaging = COMMUNITY_NAME;
3846
try {
39-
TimefoldSolverEnterpriseService.load();
40-
packaging = "Enterprise Edition";
47+
load();
48+
packaging = ENTERPRISE_NAME;
4149
} catch (Exception e) {
4250
// No need to do anything, just checking if Enterprise exists.
4351
}
44-
var version = SolverFactory.class.getPackage().getImplementationVersion();
45-
return packaging + " " + (version == null ? "(Development snapshot)" : "v" + version);
52+
var version = getVersionString(SolverFactory.class);
53+
return packaging + " " + version;
54+
}
55+
56+
private static String getVersionString(Class<?> clz) {
57+
var version = clz.getPackage().getImplementationVersion();
58+
return (version == null ? DEVELOPMENT_SNAPSHOT : "v" + version);
4659
}
4760

4861
static TimefoldSolverEnterpriseService load() throws ClassNotFoundException, NoSuchMethodException,
@@ -54,16 +67,30 @@ static TimefoldSolverEnterpriseService load() throws ClassNotFoundException, NoS
5467
}
5568

5669
static TimefoldSolverEnterpriseService loadOrFail(Feature feature) {
70+
TimefoldSolverEnterpriseService service;
5771
try {
58-
return load();
72+
service = load();
5973
} catch (Exception cause) {
6074
throw new IllegalStateException("""
61-
%s requested but Timefold Solver Enterprise Edition not found on classpath
62-
Either add the ai.timefold.solver.enterprise:timefold-solver-enterprise-core dependency,
63-
or %s.
64-
"Note: Timefold Solver Enterprise Edition is a commercial product."""
65-
.formatted(feature.getName(), feature.getWorkaround()), cause);
75+
%s requested but %s %s not found on classpath.
76+
Either add the %s dependency, or %s.
77+
Note: %s %s is a commercial product. Visit https://timefold.ai to find out more."""
78+
.formatted(feature.getName(), SOLVER_NAME, ENTERPRISE_NAME, feature.getWorkaround(),
79+
ENTERPRISE_COORDINATES, SOLVER_NAME, ENTERPRISE_NAME),
80+
cause);
81+
}
82+
var communityVersion = getVersionString(TimefoldSolverEnterpriseService.class);
83+
var enterpriseVersion = getVersionString(service.getClass());
84+
if (Objects.equals(communityVersion, enterpriseVersion)) { // Identical versions.
85+
return service;
86+
} else if (enterpriseVersion.equals(DEVELOPMENT_SNAPSHOT)) { // Don't enforce when running Enterprise tests.
87+
return service;
6688
}
89+
throw new IllegalStateException("""
90+
Detected mismatch between versions of %s %s (%s) and %s (%s).
91+
Ensure your project uses the same version of %s and %s dependencies."""
92+
.formatted(SOLVER_NAME, COMMUNITY_NAME, communityVersion, ENTERPRISE_NAME, enterpriseVersion,
93+
COMMUNITY_COORDINATES, ENTERPRISE_COORDINATES));
6794
}
6895

6996
Class<? extends ConstraintProvider>

docs/src/modules/ROOT/pages/enterprise-edition/enterprise-edition.adoc

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,22 @@
55

66
Timefold Solver Enterprise Edition is a commercial product that offers additional features,
77
such as <<nearbySelection,nearby selection>> and <<multithreadedSolving,multi-threaded solving>>.
8-
These features are essential to scale out to very large datasets.
8+
These features are essential to scale out to huge datasets.
9+
10+
Unlike Timefold Solver Community Edition, the Enterprise Edition is not open-source.
11+
You are allowed to use Timefold Solver Enterprise Edition for evaluation and development.
12+
Please contact https://timefold.ai/contact[contact Timefold]
13+
to obtain the credentials necessary to start your evaluation.
914

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

16-
Unlike Timefold Solver Community Edition,
17-
the Enterprise Edition is not open-source.
18-
1918

2019
[#switchToEnterpriseEdition]
2120
== Switch to Enterprise Edition
2221

23-
In order to switch from Timefold Solver Community Edition to Enterprise Edition,
24-
first reference the Enterprise Edition Maven repository in your project.
22+
To switch from Timefold Solver Community Edition to Enterprise Edition,
23+
first reference the Enterprise Edition Maven repository in your project:
2524

2625
[tabs]
2726
====
@@ -44,6 +43,26 @@ Add the following repository to your `pom.xml`:
4443
...
4544
</project>
4645
----
46+
47+
Then create `.m2/settings.xml` in your home directory with the following content:
48+
49+
[source,xml,options="nowrap"]
50+
----
51+
<settings>
52+
...
53+
<servers>
54+
<server>
55+
<!-- Replace "my_username" and "my_password" with credentials obtained from a Timefold representative. -->
56+
<id>timefold-solver-enterprise</id>
57+
<username>my_username</username>
58+
<password>my_password</password>
59+
</server>
60+
</servers>
61+
...
62+
</settings>
63+
----
64+
65+
See https://maven.apache.org/settings.html[Settings Reference] for more information on Maven settings.
4766
--
4867
Gradle::
4968
+
@@ -56,14 +75,21 @@ repositories {
5675
mavenCentral()
5776
maven {
5877
url "https://timefold.jfrog.io/artifactory/releases/"
78+
credentials { // Replace "my_username" and "my_password" with credentials obtained from a Timefold representative.
79+
username "my_username"
80+
password "my_password"
81+
}
82+
authentication {
83+
basic(BasicAuthentication)
84+
}
5985
}
6086
}
6187
----
6288
--
6389
====
6490

65-
Having done that the above, replace references to Community Edition artifacts by their Enterprise Edition counterparts
66-
as shown in the table below.
91+
Having done the above, replace references to Community Edition artifacts by their Enterprise Edition counterparts
92+
as shown in the following table:
6793

6894
|===
6995
|Community Edition|Enterprise Edition

docs/src/modules/ROOT/pages/upgrade-and-migration/upgrade-to-latest-version.adoc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,27 @@ Every upgrade note indicates how likely your code will be affected by that chang
5656
- icon:eye[] *Recommended*: Does not affect backwards compatibility, but you probably want to be aware.
5757
5858
The upgrade recipe often lists the changes as they apply to Java code.
59-
Kotlin users should translate the changes accordingly.
59+
We kindly ask Kotlin and Python users to translate the changes accordingly.
6060

6161
=== Upgrade from 1.9.0 to 1.10.0
6262

63+
.icon:eye[] Enterprise Edition Maven Repository will soon require authentication
64+
[%collapsible%open]
65+
====
66+
Timefold customers newly need to authenticate to access the Enterprise Edition Maven Repository.
67+
If you are a Timefold customer, you should have received your credentials from Timefold by now.
68+
If you haven't, we kindly ask that you https://timefold.ai/contact[contact us].
69+
70+
If you are not a Timefold customer and you wish to retain your access to the Enterprise Edition Maven Repository,
71+
you can https://timefold.ai/contact[contact us] to start your evaluation.
72+
There are https://timefold.ai/pricing[many benefits] to being a Timefold customer.
73+
74+
For more information on setting up the Enterprise Edition Maven Repository,
75+
see xref:enterprise-edition/enterprise-edition.adoc#switchToEnterpriseEdition[the Enterprise Edition documentation].
76+
====
77+
78+
'''
79+
6380
.icon:info-circle[role=yellow] `LookupStrategyType` deprecated for removal
6481
[%collapsible%open]
6582
====

0 commit comments

Comments
 (0)