Skip to content

Commit

Permalink
chore: upgrade to tapestry 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
ydylla committed Aug 20, 2021
1 parent 21b0a62 commit aa346de
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 87 deletions.
13 changes: 6 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ plugins {

description = "Use React together with Tapestry"
group = "de.eddyson"
version = "0.34.0"
version = "0.35.0"

def versions= [
tapestry: '5.6.1',
slf4j: '1.7.31',
tapestry: '5.7.3',
slf4j: '1.7.32',

// test scopes
spock: '1.3-groovy-2.5',
geb: '4.1',
selenium: '3.141.59'
]
Expand Down Expand Up @@ -52,12 +51,12 @@ dependencies {
exclude group:'com.google.javascript', module: 'closure-compiler'
exclude group:'com.github.sommeri', module: 'less4j'
}
implementation "commons-io:commons-io:2.6"
implementation "commons-io:commons-io:2.11.0"
implementation "org.mozilla:rhino:1.7.13" // DNK-2311

testImplementation "javax.servlet:javax.servlet-api:4.0.1"
testImplementation "org.spockframework:spock-tapestry:$versions.spock"
testImplementation "com.github.eddyson-de:tapestry-geb:0.45.2"
testImplementation "org.apache.tapestry:tapestry-spock:$versions.tapestry"
testImplementation "com.github.eddyson-de:tapestry-geb:0.46.0"
testImplementation "org.gebish:geb-spock:$versions.geb"
testImplementation "org.seleniumhq.selenium:selenium-firefox-driver:$versions.selenium"
testImplementation "org.seleniumhq.selenium:selenium-chrome-driver:$versions.selenium"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package de.eddyson.tapestry.react.modules;

import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.ObjectLocator;
import org.apache.tapestry5.ioc.annotations.Contribute;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.ioc.services.FactoryDefaults;
import org.apache.tapestry5.ioc.services.SymbolProvider;

import de.eddyson.tapestry.react.ReactSymbols;
import de.eddyson.tapestry.react.components.ReactUtilities;
import de.eddyson.tapestry.react.services.BabelCompiler;
import de.eddyson.tapestry.react.services.impl.NodeBabelCompiler;
import de.eddyson.tapestry.react.services.impl.RhinoBabelCompiler;
import org.apache.tapestry5.commons.MappedConfiguration;
import org.apache.tapestry5.commons.ObjectLocator;
import org.apache.tapestry5.ioc.annotations.Contribute;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.ioc.services.FactoryDefaults;
import org.apache.tapestry5.ioc.services.SymbolProvider;

public final class ReactCoreModule {

Expand Down
33 changes: 16 additions & 17 deletions src/main/java/de/eddyson/tapestry/react/modules/ReactModule.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package de.eddyson.tapestry.react.modules;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.StandardCharsets;

import org.apache.tapestry5.Link;
import de.eddyson.tapestry.react.ReactSymbols;
import de.eddyson.tapestry.react.requestfilters.ReactAPIFilter;
import de.eddyson.tapestry.react.services.impl.BabelResourceTransformer;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.commons.Configuration;
import org.apache.tapestry5.commons.MappedConfiguration;
import org.apache.tapestry5.commons.OrderedConfiguration;
import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.http.Link;
import org.apache.tapestry5.http.services.RequestFilter;
import org.apache.tapestry5.http.services.RequestGlobals;
import org.apache.tapestry5.http.services.RequestHandler;
import org.apache.tapestry5.internal.util.VirtualResource;
import org.apache.tapestry5.internal.webresources.CacheMode;
import org.apache.tapestry5.internal.webresources.ResourceTransformerFactory;
import org.apache.tapestry5.ioc.Configuration;
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.OrderedConfiguration;
import org.apache.tapestry5.ioc.annotations.Autobuild;
import org.apache.tapestry5.ioc.annotations.Contribute;
import org.apache.tapestry5.ioc.annotations.ImportModule;
Expand All @@ -30,19 +30,18 @@
import org.apache.tapestry5.services.MarkupRenderer;
import org.apache.tapestry5.services.MarkupRendererFilter;
import org.apache.tapestry5.services.PageRenderLinkSource;
import org.apache.tapestry5.services.RequestFilter;
import org.apache.tapestry5.services.RequestGlobals;
import org.apache.tapestry5.services.RequestHandler;
import org.apache.tapestry5.services.assets.ResourceTransformer;
import org.apache.tapestry5.services.assets.StreamableResourceSource;
import org.apache.tapestry5.services.javascript.JavaScriptModuleConfiguration;
import org.apache.tapestry5.services.javascript.ModuleManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.eddyson.tapestry.react.ReactSymbols;
import de.eddyson.tapestry.react.requestfilters.ReactAPIFilter;
import de.eddyson.tapestry.react.services.impl.BabelResourceTransformer;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.StandardCharsets;

@ImportModule(ReactCoreModule.class)
public final class ReactModule {
Expand Down Expand Up @@ -148,7 +147,7 @@ public URL toURL() {

@Contribute(MarkupRenderer.class)
public static void prepareHTMLPageOnRender(final OrderedConfiguration<MarkupRendererFilter> configuration,
final RequestGlobals requestGlobals, final PageRenderLinkSource pageRenderLinkSource) {
final RequestGlobals requestGlobals, final PageRenderLinkSource pageRenderLinkSource) {
configuration.add("AddPageName", new MarkupRendererFilter() {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package de.eddyson.tapestry.react.requestfilters;

import java.io.IOException;
import java.io.PrintWriter;

import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.alerts.Alert;
import org.apache.tapestry5.alerts.AlertStorage;
import org.apache.tapestry5.http.services.Request;
import org.apache.tapestry5.http.services.RequestFilter;
import org.apache.tapestry5.http.services.RequestHandler;
import org.apache.tapestry5.http.services.Response;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.ApplicationStateManager;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.RequestFilter;
import org.apache.tapestry5.services.RequestHandler;
import org.apache.tapestry5.services.Response;
import org.slf4j.Logger;

import java.io.IOException;
import java.io.PrintWriter;

public class ReactAPIFilter implements RequestFilter {

// TODO this should be configurable via a symbol
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package de.eddyson.tapestry.react.services.impl;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Map;

import de.eddyson.tapestry.react.ReactSymbols;
import de.eddyson.tapestry.react.services.BabelCompiler;
import org.apache.commons.io.IOUtils;
import org.apache.tapestry5.ContentType;
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.commons.Resource;
import org.apache.tapestry5.http.ContentType;
import org.apache.tapestry5.internal.InternalConstants;
import org.apache.tapestry5.ioc.Resource;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.services.assets.ResourceDependencies;
import org.apache.tapestry5.services.assets.ResourceTransformer;

import de.eddyson.tapestry.react.ReactSymbols;
import de.eddyson.tapestry.react.services.BabelCompiler;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Map;

public class BabelResourceTransformer implements ResourceTransformer {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package de.eddyson.tapestry.react.services.impl;

import de.eddyson.tapestry.react.services.BabelCompiler;
import org.apache.commons.io.IOUtils;
import org.apache.tapestry5.commons.Resource;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.internal.util.ClasspathResource;
import org.apache.tapestry5.json.JSONObject;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -10,14 +17,6 @@
import java.util.Map;
import java.util.Map.Entry;

import org.apache.commons.io.IOUtils;
import org.apache.tapestry5.ioc.Resource;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.internal.util.ClasspathResource;
import org.apache.tapestry5.json.JSONObject;

import de.eddyson.tapestry.react.services.BabelCompiler;

public class NodeBabelCompiler implements BabelCompiler {
private final static Charset UTF8 = StandardCharsets.UTF_8;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package de.eddyson.tapestry.react.services.impl;

import java.util.HashMap;
import java.util.Map;

import de.eddyson.tapestry.react.services.BabelCompiler;
import org.apache.tapestry5.commons.Resource;
import org.apache.tapestry5.internal.webresources.RhinoExecutor;
import org.apache.tapestry5.internal.webresources.RhinoExecutorPool;
import org.apache.tapestry5.ioc.OperationTracker;
import org.apache.tapestry5.ioc.Resource;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.internal.util.ClasspathResource;
import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
import org.mozilla.javascript.NativeObject;

import de.eddyson.tapestry.react.services.BabelCompiler;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RhinoBabelCompiler implements BabelCompiler {

Expand All @@ -26,9 +25,8 @@ public RhinoBabelCompiler(final OperationTracker tracker) {

public RhinoBabelCompiler(final OperationTracker tracker, final Resource mainCompiler) {
executorPool = new RhinoExecutorPool(tracker,
CollectionFactory.<Resource, Resource>newList(mainCompiler,
new ClasspathResource(RhinoBabelCompiler.class.getClassLoader(),
"de/eddyson/tapestry/react/services/babel-compiler-wrapper.js")));
List.of(mainCompiler, new ClasspathResource(RhinoBabelCompiler.class.getClassLoader(),
"de/eddyson/tapestry/react/services/babel-compiler-wrapper.js")));
}

private static String getString(final NativeObject object, final String key) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package de.eddyson.tapestry.react

import de.eddyson.tapestry.react.modules.ReactModule
import de.eddyson.tapestry.react.services.impl.RhinoBabelCompiler
import org.apache.tapestry5.SymbolConstants
import org.apache.tapestry5.internal.InternalSymbols
import org.apache.tapestry5.commons.MappedConfiguration
import org.apache.tapestry5.commons.Resource
import org.apache.tapestry5.http.services.ApplicationGlobals
import org.apache.tapestry5.internal.test.PageTesterContext
import org.apache.tapestry5.ioc.MappedConfiguration
import org.apache.tapestry5.ioc.Resource
import org.apache.tapestry5.ioc.annotations.Autobuild
import org.apache.tapestry5.ioc.annotations.ImportModule
import org.apache.tapestry5.ioc.annotations.Inject
import org.apache.tapestry5.ioc.internal.util.ClasspathResource
import org.apache.tapestry5.modules.AssetsModule
import org.apache.tapestry5.modules.TapestryModule
import org.apache.tapestry5.services.ApplicationGlobals
import org.apache.tapestry5.webresources.modules.WebResourcesModule

import de.eddyson.tapestry.react.services.impl.RhinoBabelCompiler
import spock.lang.Shared
import spock.lang.Specification

Expand Down Expand Up @@ -135,7 +133,7 @@ class BabelCompilerSpec extends Specification {
public static class TestModule {

def contributeApplicationDefaults(MappedConfiguration configuration){
configuration.add(InternalSymbols.APP_NAME, "test")
configuration.add("tapestry.app-name", "test")
configuration.add("tapestry.app-package", "react")
configuration.add(SymbolConstants.MINIFICATION_ENABLED, false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ package de.eddyson.tapestry.react
import de.eddyson.tapestry.react.modules.ReactModule
import de.eddyson.tapestry.react.services.impl.NodeBabelCompiler
import org.apache.tapestry5.SymbolConstants
import org.apache.tapestry5.internal.InternalSymbols
import org.apache.tapestry5.commons.MappedConfiguration
import org.apache.tapestry5.commons.Resource
import org.apache.tapestry5.http.services.ApplicationGlobals
import org.apache.tapestry5.internal.test.PageTesterContext
import org.apache.tapestry5.ioc.MappedConfiguration
import org.apache.tapestry5.ioc.Resource
import org.apache.tapestry5.ioc.annotations.Autobuild
import org.apache.tapestry5.ioc.annotations.ImportModule
import org.apache.tapestry5.ioc.annotations.Inject
import org.apache.tapestry5.ioc.internal.util.ClasspathResource
import org.apache.tapestry5.modules.AssetsModule
import org.apache.tapestry5.modules.TapestryModule
import org.apache.tapestry5.services.ApplicationGlobals
import org.apache.tapestry5.webresources.modules.WebResourcesModule
import spock.lang.Shared
import spock.lang.Specification
Expand All @@ -33,8 +32,7 @@ class NodeBabelCompilerSpec extends Specification {
}

def compile(Resource resource){
def inputs = [:]
inputs.put(resource.file, resource.openStream().text)
Map<String,String> inputs = [(resource.file):resource.openStream().text]
return nodeBabelCompiler.compile(inputs, true, false, true, true, false)[resource.file]
}

Expand Down Expand Up @@ -83,7 +81,7 @@ class NodeBabelCompilerSpec extends Specification {
public static class TestModule {

def contributeApplicationDefaults(MappedConfiguration configuration){
configuration.add(InternalSymbols.APP_NAME, "test")
configuration.add("tapestry.app-name", "test")
configuration.add("tapestry.app-package", "react")
configuration.add(SymbolConstants.MINIFICATION_ENABLED, false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ package de.eddyson.tapestry.react

import de.eddyson.tapestry.react.modules.ReactModule
import org.apache.tapestry5.SymbolConstants
import org.apache.tapestry5.internal.InternalSymbols
import org.apache.tapestry5.commons.MappedConfiguration
import org.apache.tapestry5.commons.Resource
import org.apache.tapestry5.http.services.ApplicationGlobals
import org.apache.tapestry5.http.services.Request
import org.apache.tapestry5.http.services.RequestGlobals
import org.apache.tapestry5.internal.services.assets.ResourceChangeTracker
import org.apache.tapestry5.internal.test.PageTesterContext
import org.apache.tapestry5.ioc.MappedConfiguration
import org.apache.tapestry5.ioc.Resource
import org.apache.tapestry5.ioc.annotations.ImportModule
import org.apache.tapestry5.ioc.annotations.Inject
import org.apache.tapestry5.modules.AssetsModule
import org.apache.tapestry5.modules.TapestryModule
import org.apache.tapestry5.services.ApplicationGlobals
import org.apache.tapestry5.services.Request
import org.apache.tapestry5.services.RequestGlobals
import org.apache.tapestry5.services.assets.StreamableResource
import org.apache.tapestry5.services.assets.StreamableResourceProcessing
import org.apache.tapestry5.services.assets.StreamableResourceSource
Expand Down Expand Up @@ -74,7 +73,7 @@ class ProductionModuleSpec extends Specification {
public static class TestModule {

def contributeApplicationDefaults(MappedConfiguration configuration){
configuration.add(InternalSymbols.APP_NAME, "test")
configuration.add("tapestry.app-name", "test")
configuration.add("tapestry.app-package", "react")
configuration.add(SymbolConstants.MINIFICATION_ENABLED, false)
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/de/eddyson/testapp/modules/TestModule.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.eddyson.testapp.modules;

import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.commons.MappedConfiguration;
import org.apache.tapestry5.ioc.annotations.Contribute;
import org.apache.tapestry5.ioc.annotations.ImportModule;
import org.apache.tapestry5.ioc.services.ApplicationDefaults;
Expand Down

0 comments on commit aa346de

Please sign in to comment.