Added more source code splitting logic for trial licenses
This commit is contained in:
parent
7725787591
commit
e4b616e8fd
@ -51,22 +51,35 @@ import org.jooq.xtend.Generators
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
class OSS extends Generators {
|
||||
class RemoveProCode {
|
||||
def static void main(String[] args) {
|
||||
Splitter::split("pro", "/../workspace-jooq-oss");
|
||||
}
|
||||
}
|
||||
|
||||
class RemoveTrialCode {
|
||||
def static void main(String[] args) {
|
||||
Splitter::split("trial", "/../workspace-jooq-pro");
|
||||
}
|
||||
}
|
||||
|
||||
class Splitter extends Generators {
|
||||
|
||||
static ExecutorService ex;
|
||||
|
||||
def static void main(String[] args) {
|
||||
String token;
|
||||
|
||||
def static void split(String token, String workspace) {
|
||||
ex = Executors::newFixedThreadPool(4);
|
||||
|
||||
val oss = new OSS();
|
||||
val splitter = new Splitter(token);
|
||||
|
||||
val workspaceIn = new File("../..").canonicalFile;
|
||||
val workspaceOut = new File(workspaceIn.canonicalPath + "/../workspace-jooq-oss").canonicalFile;
|
||||
val workspaceOut = new File(workspaceIn.canonicalPath + workspace).canonicalFile;
|
||||
|
||||
for (project : workspaceIn.listFiles[f | f.name.startsWith("jOOQ")]) {
|
||||
val in = new File(workspaceIn, project.name);
|
||||
val out = new File(workspaceOut, project.name);
|
||||
oss.transform(in, out, in);
|
||||
splitter.transform(in, out, in);
|
||||
}
|
||||
|
||||
ex.shutdown;
|
||||
@ -101,7 +114,7 @@ class OSS extends Generators {
|
||||
transform(inRoot, outRoot, file);
|
||||
}
|
||||
}
|
||||
else if (in.name.equals("LICENSE.txt")) {
|
||||
else if (token == "pro" && in.name.equals("LICENSE.txt")) {
|
||||
ex.submit[ |
|
||||
write(out, '''
|
||||
Copyright (c) 2009-2013, Data Geekery GmbH (http://www.datageekery.com)
|
||||
@ -159,14 +172,17 @@ For more information, please visit: http://www.jooq.org/licenses''');
|
||||
val replaceAll = new ArrayList<ImmutablePair<Pattern, String>>();
|
||||
val replaceFirst = new ArrayList<ImmutablePair<Pattern, String>>();
|
||||
|
||||
new() {
|
||||
new(String token) {
|
||||
this.token = token;
|
||||
|
||||
// Replace a couple of imports
|
||||
replaceFirst.add(new ImmutablePair(compile('''import org\.jooq\.(ArrayConstant|ArrayRecord|impl\.ArrayRecordImpl|impl\.FlashbackTable.*?);'''), "// ..."));
|
||||
replaceFirst.add(new ImmutablePair(compile('''import static org\.jooq\.impl\.DSL\.(cube|grouping|groupingId|groupingSets);'''), "// ..."));
|
||||
|
||||
// Replace the Java / Scala / Xtend license header
|
||||
replaceFirst.add(new ImmutablePair(compile('''(?s:/\*\*[\r\n] \* Copyright.*?eula[\r\n] \*/)'''), '''
|
||||
if (token == "pro") {
|
||||
|
||||
// Replace a couple of imports
|
||||
replaceFirst.add(new ImmutablePair(compile('''import org\.jooq\.(ArrayConstant|ArrayRecord|impl\.ArrayRecordImpl|impl\.FlashbackTable.*?);'''), "// ..."));
|
||||
replaceFirst.add(new ImmutablePair(compile('''import static org\.jooq\.impl\.DSL\.(cube|grouping|groupingId|groupingSets);'''), "// ..."));
|
||||
|
||||
// Replace the Java / Scala / Xtend license header
|
||||
replaceFirst.add(new ImmutablePair(compile('''(?s:/\*\*[\r\n] \* Copyright.*?eula[\r\n] \*/)'''), '''
|
||||
/**
|
||||
* Copyright (c) 2009-2013, Data Geekery GmbH (http://www.datageekery.com)
|
||||
* All rights reserved.
|
||||
@ -208,25 +224,26 @@ For more information, please visit: http://www.jooq.org/licenses''');
|
||||
*
|
||||
*/'''));
|
||||
|
||||
// Remove sections of commercial code
|
||||
translateAll.add(compile('''(?s:(/\* \[pro\])( \*.*?/\* )(\[/pro\] \*/))'''));
|
||||
translateAll.add(compile('''(?s:(<!-- \[pro\])( -->.*?<!-- )(\[/pro\] -->))'''));
|
||||
|
||||
for (d : SQLDialect::values.filter[d | d.commercial]) {
|
||||
|
||||
// Remove commercial dialects from @Support annotations
|
||||
replaceAll.add(new ImmutablePair(compile('''(?s:(\@Support\([^\)]*?),\s*\b«d.name»\b([^\)]*?\)))'''), "$1$2"));
|
||||
replaceAll.add(new ImmutablePair(compile('''(?s:(\@Support\([^\)]*?)\b«d.name»\b,\s*([^\)]*?\)))'''), "$1$2"));
|
||||
replaceAll.add(new ImmutablePair(compile('''(?s:(\@Support\([^\)]*?)\s*\b«d.name»\b\s*([^\)]*?\)))'''), "$1$2"));
|
||||
|
||||
// Remove commercial dialects from Arrays.asList() expressions
|
||||
replaceAll.add(new ImmutablePair(compile('''(asList\([^\)]*?),\s*\b«d.name»\b([^\)]*?\))'''), "$1$2"));
|
||||
replaceAll.add(new ImmutablePair(compile('''(asList\([^\)]*?)\b«d.name»\b,\s*([^\)]*?\))'''), "$1$2"));
|
||||
replaceAll.add(new ImmutablePair(compile('''(asList\([^\)]*?)\s*\b«d.name»\b\s*([^\)]*?\))'''), "$1$2"));
|
||||
|
||||
// Remove commercial dialects from imports
|
||||
replaceAll.add(new ImmutablePair(compile('''import (static )?org\.jooq\.SQLDialect\.«d.name»;'''), "// ..."));
|
||||
replaceAll.add(new ImmutablePair(compile('''import (static )?org\.jooq\.util\.«d.name.toLowerCase»\..*?;'''), "// ..."));
|
||||
for (d : SQLDialect::values.filter[d | d.commercial]) {
|
||||
|
||||
// Remove commercial dialects from @Support annotations
|
||||
replaceAll.add(new ImmutablePair(compile('''(?s:(\@Support\([^\)]*?),\s*\b«d.name»\b([^\)]*?\)))'''), "$1$2"));
|
||||
replaceAll.add(new ImmutablePair(compile('''(?s:(\@Support\([^\)]*?)\b«d.name»\b,\s*([^\)]*?\)))'''), "$1$2"));
|
||||
replaceAll.add(new ImmutablePair(compile('''(?s:(\@Support\([^\)]*?)\s*\b«d.name»\b\s*([^\)]*?\)))'''), "$1$2"));
|
||||
|
||||
// Remove commercial dialects from Arrays.asList() expressions
|
||||
replaceAll.add(new ImmutablePair(compile('''(asList\([^\)]*?),\s*\b«d.name»\b([^\)]*?\))'''), "$1$2"));
|
||||
replaceAll.add(new ImmutablePair(compile('''(asList\([^\)]*?)\b«d.name»\b,\s*([^\)]*?\))'''), "$1$2"));
|
||||
replaceAll.add(new ImmutablePair(compile('''(asList\([^\)]*?)\s*\b«d.name»\b\s*([^\)]*?\))'''), "$1$2"));
|
||||
|
||||
// Remove commercial dialects from imports
|
||||
replaceAll.add(new ImmutablePair(compile('''import (static )?org\.jooq\.SQLDialect\.«d.name»;'''), "// ..."));
|
||||
replaceAll.add(new ImmutablePair(compile('''import (static )?org\.jooq\.util\.«d.name.toLowerCase»\..*?;'''), "// ..."));
|
||||
}
|
||||
}
|
||||
|
||||
// Remove sections of delimited code
|
||||
translateAll.add(compile('''(?s:(/\* \[«token»\])( \*.*?/\* )(\[/«token»\] \*/))'''));
|
||||
translateAll.add(compile('''(?s:(<!-- \[«token»\])( -->.*?<!-- )(\[/«token»\] -->))'''));
|
||||
}
|
||||
}
|
||||
@ -247,6 +247,18 @@ abstract class AbstractQuery extends AbstractQueryPart implements Query, Attacha
|
||||
|
||||
@Override
|
||||
public final int execute() {
|
||||
/* [pro] */ /* [trial] */
|
||||
|
||||
// Please do not remove or circumvent the below logic
|
||||
// --------------------------------------------------
|
||||
// This concurrency sealing friendly reminder that you are using
|
||||
// a commercial version of jOOQ with a free 30 days trial license. We do
|
||||
// not want to bother our honest customers with annoying license
|
||||
// verification. So, if you want to remove the below synchronization,
|
||||
// consider purchasing a license from http://www.jooq.org/download
|
||||
synchronized (AbstractQuery.class) {
|
||||
/* [/trial] */ /* [/pro] */
|
||||
|
||||
if (isExecutable()) {
|
||||
|
||||
// Get the attached configuration of this query
|
||||
@ -334,6 +346,10 @@ abstract class AbstractQuery extends AbstractQueryPart implements Query, Attacha
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* [pro] */ /* [trial] */
|
||||
}
|
||||
/* [/trial] */ /* [/pro] */
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -374,7 +374,7 @@ class DefaultExecuteContext implements ExecuteContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String sql() {
|
||||
public final String sql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
|
||||
@ -59,12 +59,14 @@ import java.util.regex.Pattern;
|
||||
import org.jooq.BindContext;
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Constants;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Param;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.QueryPartInternal;
|
||||
import org.jooq.RenderContext;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.VisitContext;
|
||||
import org.jooq.VisitListener;
|
||||
@ -333,13 +335,30 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String render() {
|
||||
public final String render() {
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String render(QueryPart part) {
|
||||
return new DefaultRenderContext(this).visit(part).render();
|
||||
public final String render(QueryPart part) {
|
||||
RenderContext local = new DefaultRenderContext(this).visit(part);
|
||||
|
||||
/* [pro] */ /* [trial] */
|
||||
|
||||
// Please do not remove or circumvent the below logic
|
||||
// --------------------------------------------------
|
||||
// This generated SQL comment is a friendly reminder that you are using
|
||||
// a commercial version of jOOQ with a free 30 days trial license. We do
|
||||
// not want to bother our honest customers with annoying license
|
||||
// verification. So, if you want to remove the below notice, consider
|
||||
// purchasing a license from http://www.jooq.org/download
|
||||
|
||||
if (part instanceof Select)
|
||||
local.sql(" -- SQL rendered with a free trial version of jOOQ " + Constants.FULL_VERSION);
|
||||
|
||||
/* [/trial] */ /* [/pro] */
|
||||
|
||||
return local.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
Reference in New Issue
Block a user