Skip to content

Commit c62d6da

Browse files
committed
feat!: Add runtime license checking for Flow 23.5
1 parent 5639b5a commit c62d6da

15 files changed

Lines changed: 160 additions & 42 deletions

File tree

‎flow-client/bnd.bnd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ Bundle-SymbolicName: ${project.groupId}.flow.client
22
Bundle-Name: Flow Client Engine
33
Bundle-Version: ${osgi.bundle.version}
44
Bundle-RequiredExecutionEnvironment: JavaSE-11
5-
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
5+
Bundle-License: https://vaadin.com/commercial-license-and-service-terms
66
Import-Package: !*
77
Export-Package: !*

‎flow-data/bnd.bnd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Bundle-SymbolicName: ${project.groupId}.flow.data
22
Bundle-Name: Vaadin Flow Data
33
Bundle-Version: ${osgi.bundle.version}
44
Bundle-RequiredExecutionEnvironment: JavaSE-11
5-
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
5+
Bundle-License: https://vaadin.com/commercial-license-and-service-terms
66
Import-Package: javax.validation*;resolution:=optional;version='${javax.validation.version}',\
77
com.vaadin.flow*;version='[${osgi.bundle.version},${osgi.bundle.version}]',\
88
*

‎flow-dnd/bnd.bnd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ Bundle-SymbolicName: ${project.groupId}.flow.dnd
22
Bundle-Name: Vaadin Flow DnD Support
33
Bundle-Version: ${osgi.bundle.version}
44
Bundle-RequiredExecutionEnvironment: JavaSE-11
5-
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
5+
Bundle-License: https://vaadin.com/commercial-license-and-service-terms
66
Export-Package: !com.vaadin.flow.component.dnd.internal*,\
77
com.vaadin.flow.component.dnd*;-noimport:=true

‎flow-html-components/bnd.bnd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Bundle-SymbolicName: ${project.groupId}.flow.html.components
22
Bundle-Name: Vaadin Flow Html Components
33
Bundle-Version: ${osgi.bundle.version}
44
Bundle-RequiredExecutionEnvironment: JavaSE-11
5-
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
5+
Bundle-License: https://vaadin.com/commercial-license-and-service-terms
66
Import-Package: com.vaadin.flow*;version='[${osgi.bundle.version},${osgi.bundle.version}]',\
77
*
88
Export-Package: com.vaadin.flow.component.html*;-noimport:=true

‎flow-lit-template/bnd.bnd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ Bundle-SymbolicName: ${project.groupId}.flow.lit-template
22
Bundle-Name: Vaadin Flow Lit Templates Support
33
Bundle-Version: ${osgi.bundle.version}
44
Bundle-RequiredExecutionEnvironment: JavaSE-11
5-
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
5+
Bundle-License: https://vaadin.com/commercial-license-and-service-terms
66
Export-Package: com.vaadin.flow.component.littemplate;-noimport:=true
77

‎flow-plugins/flow-plugin-base/bnd.bnd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Bundle-SymbolicName: ${project.groupId}.flow.plugin.base
22
Bundle-Name: Vaadin Flow Plugin Base
33
Bundle-Version: ${osgi.bundle.version}
44
Bundle-RequiredExecutionEnvironment: JavaSE-11
5-
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
5+
Bundle-License: https://vaadin.com/commercial-license-and-service-terms
66
-privatepackage: \
77
com.vaadin.flow.server.scanner,\
88
com.vaadin.flow.utils

‎flow-plugins/flow-plugin-base/src/main/java/com/vaadin/flow/plugin/base/BuildFrontendUtil.java‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import java.net.URISyntaxException;
1818
import java.net.URL;
1919
import java.nio.charset.StandardCharsets;
20-
import java.nio.file.Paths;
2120
import java.util.ArrayList;
2221
import java.util.Arrays;
2322
import java.util.Collections;
@@ -34,6 +33,7 @@
3433
import com.vaadin.flow.server.Constants;
3534
import com.vaadin.flow.server.ExecutionFailedException;
3635
import com.vaadin.flow.server.InitParameters;
36+
import com.vaadin.flow.server.Version;
3737
import com.vaadin.flow.server.frontend.CvdlProducts;
3838
import com.vaadin.flow.server.frontend.FrontendTools;
3939
import com.vaadin.flow.server.frontend.FrontendToolsSettings;
@@ -46,25 +46,23 @@
4646
import com.vaadin.pro.licensechecker.BuildType;
4747
import com.vaadin.pro.licensechecker.LicenseChecker;
4848
import com.vaadin.pro.licensechecker.Product;
49-
49+
import elemental.json.Json;
50+
import elemental.json.JsonArray;
51+
import elemental.json.JsonObject;
52+
import elemental.json.impl.JsonUtil;
5053
import org.apache.commons.io.FileUtils;
5154
import org.apache.commons.io.IOUtils;
5255
import org.slf4j.Logger;
5356
import org.slf4j.LoggerFactory;
5457
import org.zeroturnaround.exec.InvalidExitValueException;
5558
import org.zeroturnaround.exec.ProcessExecutor;
5659

57-
import elemental.json.Json;
58-
import elemental.json.JsonArray;
59-
import elemental.json.JsonObject;
60-
import elemental.json.impl.JsonUtil;
61-
6260
import static com.vaadin.flow.server.Constants.CONNECT_APPLICATION_PROPERTIES_TOKEN;
6361
import static com.vaadin.flow.server.Constants.CONNECT_JAVA_SOURCE_FOLDER_TOKEN;
64-
import static com.vaadin.flow.server.Constants.JAVA_RESOURCE_FOLDER_TOKEN;
6562
import static com.vaadin.flow.server.Constants.CONNECT_OPEN_API_FILE_TOKEN;
6663
import static com.vaadin.flow.server.Constants.FRONTEND_TOKEN;
6764
import static com.vaadin.flow.server.Constants.GENERATED_TOKEN;
65+
import static com.vaadin.flow.server.Constants.JAVA_RESOURCE_FOLDER_TOKEN;
6866
import static com.vaadin.flow.server.Constants.NPM_TOKEN;
6967
import static com.vaadin.flow.server.Constants.PROJECT_FRONTEND_GENERATED_DIR_TOKEN;
7068
import static com.vaadin.flow.server.InitParameters.NODE_DOWNLOAD_ROOT;
@@ -417,6 +415,8 @@ private static void runFrontendBuildTool(PluginAdapterBase adapter,
417415
Map<String, String> environment, String... params)
418416
throws TimeoutException, URISyntaxException {
419417

418+
validateLicense();
419+
420420
File buildExecutable = new File(adapter.npmFolder(),
421421
NODE_MODULES + executable);
422422
if (!buildExecutable.isFile()) {
@@ -467,6 +467,11 @@ private static void runFrontendBuildTool(PluginAdapterBase adapter,
467467
validateLicenses(adapter);
468468
}
469469

470+
private static void validateLicense() {
471+
LicenseChecker.checkLicense("flow", Version.getFullVersion(),
472+
BuildType.PRODUCTION);
473+
}
474+
470475
private static void validateLicenses(PluginAdapterBase adapter) {
471476
File nodeModulesFolder = new File(adapter.npmFolder(),
472477
FrontendUtils.NODE_MODULES);

‎flow-plugins/flow-plugin-base/src/test/java/com/vaadin/flow/plugin/base/BuildFrontendUtilTest.java‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,30 @@
2323
import com.vaadin.flow.di.Lookup;
2424
import com.vaadin.flow.server.Constants;
2525
import com.vaadin.flow.server.ExecutionFailedException;
26-
import com.vaadin.flow.server.frontend.*;
26+
import com.vaadin.flow.server.Version;
27+
import com.vaadin.flow.server.frontend.EndpointGeneratorTaskFactory;
28+
import com.vaadin.flow.server.frontend.FrontendTools;
29+
import com.vaadin.flow.server.frontend.FrontendUtils;
30+
import com.vaadin.flow.server.frontend.TaskGenerateHilla;
31+
import com.vaadin.flow.server.frontend.TaskRunNpmInstall;
2732
import com.vaadin.flow.server.frontend.installer.NodeInstaller;
33+
import com.vaadin.flow.server.frontend.scanner.ClassFinder;
34+
import com.vaadin.flow.utils.LookupImpl;
35+
import com.vaadin.pro.licensechecker.BuildType;
36+
import com.vaadin.pro.licensechecker.LicenseChecker;
2837
import org.apache.commons.io.FileUtils;
2938
import org.apache.commons.io.IOUtils;
39+
import org.junit.After;
3040
import org.junit.Assert;
3141
import org.junit.Assume;
3242
import org.junit.Before;
3343
import org.junit.Test;
3444
import org.junit.rules.TemporaryFolder;
3545
import org.mockito.InOrder;
3646
import org.mockito.MockedConstruction;
47+
import org.mockito.MockedStatic;
3748
import org.mockito.Mockito;
3849

39-
import com.vaadin.flow.server.frontend.scanner.ClassFinder;
40-
import com.vaadin.flow.utils.LookupImpl;
41-
4250
public class BuildFrontendUtilTest {
4351

4452
private File baseDir;
@@ -49,8 +57,11 @@ public class BuildFrontendUtilTest {
4957

5058
private Lookup lookup;
5159

60+
private MockedStatic<LicenseChecker> licenseChecker;
61+
5262
@Before
5363
public void setup() throws IOException {
64+
licenseChecker = Mockito.mockStatic(LicenseChecker.class);
5465
TemporaryFolder tmpDir = new TemporaryFolder();
5566
tmpDir.create();
5667
baseDir = tmpDir.newFolder();
@@ -89,6 +100,11 @@ public void setup() throws IOException {
89100
}
90101
}
91102

103+
@After
104+
public void cleanup() {
105+
licenseChecker.close();
106+
}
107+
92108
@Test
93109
public void testWebpackRequiredFlagsPassedToNodeEnvironment()
94110
throws IOException, URISyntaxException, TimeoutException {
@@ -117,6 +133,10 @@ public void testWebpackRequiredFlagsPassedToNodeEnvironment()
117133
BuildFrontendUtil.runWebpack(adapter, tools);
118134

119135
// terminates successfully
136+
137+
// license check for prod build
138+
licenseChecker.verify(() -> LicenseChecker.checkLicense("flow",
139+
Version.getFullVersion(), BuildType.PRODUCTION));
120140
}
121141

122142
@Test

‎flow-polymer-template/bnd.bnd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ Bundle-SymbolicName: ${project.groupId}.flow.polymer-template
22
Bundle-Name: Vaadin Flow Polymer Templates Support
33
Bundle-Version: ${osgi.bundle.version}
44
Bundle-RequiredExecutionEnvironment: JavaSE-11
5-
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
5+
Bundle-License: https://vaadin.com/commercial-license-and-service-terms
66
Export-Package: com.vaadin.flow.component.polymertemplate,\
77
com.vaadin.flow.templatemodel,;-noimport:=true

‎flow-push/bnd.bnd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Bundle-SymbolicName: ${project.groupId}.flow.push
22
Bundle-Name: Vaadin Flow Push
33
Bundle-Version: ${osgi.bundle.version}
44
Bundle-RequiredExecutionEnvironment: JavaSE-11
5-
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
5+
Bundle-License: https://vaadin.com/commercial-license-and-service-terms
66
Import-Package: com.vaadin.flow*;version='[${osgi.bundle.version},${osgi.bundle.version}]',\
77
*
88
Export-Package: !*

0 commit comments

Comments
 (0)