embulk 0.8.29 → 0.8.30

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a6b98a48432c2038f6be1ca16d35820a7f164ba
4
- data.tar.gz: 096ef6a57634e352cf5cf9444fe8e0f0b632ab5d
3
+ metadata.gz: 07b249572fa56d1f86fcf05b0ca4ecf46336ad31
4
+ data.tar.gz: c70acaab9b51e85ec95b0b9d8265e56f52b2d236
5
5
  SHA512:
6
- metadata.gz: e257ba9a627635a144a5d08277412c7c22cead429a1a9291bc78c19fcc1ee7ee7a00e5640e27d3753185b3ce1aa52fd6be3037e0662f5800ee3066c5b65304bf
7
- data.tar.gz: 11d2f1667182706bc507d03a72c19d36bc269558c694bfbbfa64d26ff52af28843eff2573bc8f148f9a4719acb8db8e3782be5b519b016457c3263890f47ad9c
6
+ metadata.gz: e74c87466c4d63dd673c845bca64d7e8cd750b5ac00441c0d0e8a268d21674296266fadd98fafec8886d22ab017d2bf85dd0a18cd0731ec82f449545ef43ef66
7
+ data.tar.gz: 44b17054093ffea2aa5beb19c90f0aea382c8fd0f119e813f2bbf6724961877762cee52bc5da187b7694954547ba760265267c047b97ea1355579a55b7737f94
data/bin/embulk CHANGED
@@ -16,16 +16,16 @@ if RUBY_PLATFORM =~ /java/i
16
16
  # Bundler may be enabled in this path.
17
17
  ENV.delete('EMBULK_BIN_ENABLE_BUNDLE')
18
18
 
19
- # Handle environment variables before entering org.embulk.cli.EmbulkBundle.
19
+ # Handle environment variables before initializing the global JRuby instance in org.embulk.EmbulkRunner.
20
20
  # See: https://github.com/embulk/embulk/pull/604
21
21
 
22
22
  bundle_path = ENV['EMBULK_BUNDLE_PATH'].to_s
23
23
  bundle_path = nil if bundle_path.empty?
24
24
 
25
- # Search for -b or --bundle, and remove it.
25
+ # The -b or --bundle option are processed in org.embulk.EmbulkRunner. The option should be kept.
26
26
  bundle_option_index = ARGV.find_index {|arg| arg == '-b' || arg == '--bundle' }
27
27
  if bundle_option_index
28
- ARGV.slice!(bundle_option_index, 2)[1]
28
+ bundle_path = ARGV[bundle_option_index + 1]
29
29
  end
30
30
 
31
31
  if bundle_path
@@ -43,26 +43,28 @@ if RUBY_PLATFORM =~ /java/i
43
43
  ENV['GEM_PATH'] = ''
44
44
  ENV.delete('BUNDLE_GEMFILE')
45
45
  end
46
-
47
- require 'embulk/version'
48
- Java::org.embulk.cli.EmbulkBundle::checkBundleWithEmbulkVersion(ARGV,
49
- Java::JavaUtil::ArrayList.new,
50
- Embulk::VERSION_INTERNAL)
51
46
  else
52
47
  # bin/embulk is started by JRuby (embulk gem for JRuby is installed).
53
48
  # Bundler must be disabled in this path not to bother the JRuby's bundler.
49
+
50
+ # org.embulk.EmbulkRunner processes the -b or --bundle option. The option should be removed to disable Bundler.
51
+ # Search for -b or --bundle, and just remove it.
52
+ bundle_option_index = ARGV.find_index {|arg| arg == '-b' || arg == '--bundle' }
53
+ if bundle_option_index
54
+ STDERR.puts "-b or --bundle options do not work when Embulk is triggered from command line by JRuby."
55
+ ARGV.slice!(bundle_option_index, 2)[1]
56
+ end
57
+
54
58
  $LOAD_PATH << File.expand_path('../lib', File.dirname(__FILE__))
55
59
  Dir.glob("#{File.expand_path('../classpath', File.dirname(__FILE__))}/*").each do |f_jar|
56
60
  $CLASSPATH << f_jar
57
61
  end
58
- require 'embulk/version'
59
- # The ScriptingContainer instance below is the same JRuby instance with the one running this bin/embulk itself
60
- # as it's LocalContextScope.SINGLETON. The instance then inherits $LOAD_PATH and $CLASSPATH configured above.
61
- global_jruby_container = Java::org.jruby.embed.ScriptingContainer.new(
62
- Java::org.jruby.embed.LocalContextScope::SINGLETON, Java::org.jruby.embed.LocalVariableBehavior::PERSISTENT)
63
- embulk_run = Java::org.embulk.cli.EmbulkRun.new(Embulk::VERSION_INTERNAL, global_jruby_container)
64
- embulk_run.run(Java::JavaUtil::ArrayList.new(ARGV), Java::JavaUtil::ArrayList.new)
65
62
  end
63
+
64
+ require 'embulk/version'
65
+ embulk_run = Java::org.embulk.cli.EmbulkRun.new(Embulk::VERSION_INTERNAL)
66
+ embulk_run.run(Java::JavaUtil::ArrayList.new(ARGV), Java::JavaUtil::ArrayList.new)
67
+
66
68
  exit 0
67
69
  end
68
70
 
@@ -16,7 +16,7 @@ def release_projects = [project(":embulk-core"), project(":embulk-standards"), p
16
16
 
17
17
  allprojects {
18
18
  group = 'org.embulk'
19
- version = '0.8.29'
19
+ version = '0.8.30'
20
20
 
21
21
  ext {
22
22
  jrubyVersion = '9.1.5.0'
@@ -30,13 +30,12 @@ import org.jruby.embed.ScriptingContainer;
30
30
 
31
31
  public class EmbulkRun
32
32
  {
33
- public EmbulkRun(final String embulkVersion, final ScriptingContainer jrubyContainer)
33
+ public EmbulkRun(final String embulkVersion)
34
34
  {
35
35
  this.embulkVersion = embulkVersion;
36
- this.jrubyContainer = jrubyContainer;
37
36
  }
38
37
 
39
- public int run(final List<String> argsEmbulk, final List<String> argsJRuby)
38
+ public int run(final List<String> argsEmbulk, final List<String> jrubyOptions)
40
39
  {
41
40
  final EmbulkArguments arguments;
42
41
  try {
@@ -79,7 +78,7 @@ public class EmbulkRun
79
78
  case EXEC:
80
79
  case GEM:
81
80
  case IRB:
82
- return runSubcommand(subcommand, subcommandArguments, null);
81
+ return runSubcommand(subcommand, subcommandArguments, null, jrubyOptions);
83
82
  default:
84
83
  final EmbulkCommandLineParser parser = buildCommandLineParser(subcommand);
85
84
  final EmbulkCommandLine commandLine;
@@ -97,7 +96,7 @@ public class EmbulkRun
97
96
  parser.printHelp(System.err);
98
97
  return 1;
99
98
  }
100
- return runSubcommand(subcommand, subcommandArguments, commandLine);
99
+ return runSubcommand(subcommand, subcommandArguments, commandLine, jrubyOptions);
101
100
  }
102
101
  }
103
102
 
@@ -344,7 +343,8 @@ public class EmbulkRun
344
343
 
345
344
  private int runSubcommand(final EmbulkSubcommand subcommand,
346
345
  final List<String> subcommandArguments,
347
- final EmbulkCommandLine commandLine)
346
+ final EmbulkCommandLine commandLine,
347
+ final List<String> jrubyOptions)
348
348
  {
349
349
  switch (subcommand) {
350
350
  case EXAMPLE:
@@ -447,11 +447,12 @@ public class EmbulkRun
447
447
  // NOTE: |EmbulkSetup.setup| returns |EmbulkEmbed| while it stores Ruby |Embulk::EmbulkRunner(EmbulkEmbed)|
448
448
  // into Ruby |Embulk::Runner|.
449
449
  final EmbulkRunner runner = EmbulkSetup.setup(
450
+ jrubyOptions,
450
451
  commandLine.getSystemConfig(),
451
452
  commandLine.getLoadPath(),
452
453
  commandLine.getLoad(),
453
454
  commandLine.getClasspath(),
454
- this.jrubyContainer);
455
+ commandLine.getBundle());
455
456
 
456
457
  final Path configDiffPath =
457
458
  (commandLine.getConfigDiff() == null ? null : Paths.get(commandLine.getConfigDiff()));
@@ -763,5 +764,4 @@ public class EmbulkRun
763
764
  }
764
765
 
765
766
  private final String embulkVersion;
766
- private final ScriptingContainer jrubyContainer;
767
767
  }
@@ -2,6 +2,7 @@ package org.embulk.cli;
2
2
 
3
3
  import java.util.ArrayList;
4
4
  import java.util.Collections;
5
+ import org.embulk.EmbulkVersion;
5
6
 
6
7
  public class Main
7
8
  {
@@ -18,11 +19,12 @@ public class Main
18
19
  }
19
20
  }
20
21
 
21
- final String[] embulkArgs = new String[args.length - i];
22
- for (int j = 0; i < args.length; ++i, ++j) {
23
- embulkArgs[j] = args[i];
22
+ final ArrayList<String> embulkArgs = new ArrayList<String>();
23
+ for (; i < args.length; ++i) {
24
+ embulkArgs.add(args[i]);
24
25
  }
25
26
 
26
- EmbulkBundle.checkBundle(embulkArgs, Collections.unmodifiableList(jrubyOptions));
27
+ final EmbulkRun run = new EmbulkRun(EmbulkVersion.VERSION);
28
+ run.run(Collections.unmodifiableList(embulkArgs), Collections.unmodifiableList(jrubyOptions));
27
29
  }
28
30
  }
@@ -1,4 +1,4 @@
1
- package org.embulk.cli;
1
+ package org.embulk;
2
2
 
3
3
  import java.io.PrintStream;
4
4
  import java.net.URISyntaxException;
@@ -33,7 +33,6 @@ public class EmbulkGlobalJRubyScriptingContainer
33
33
  * Sets up a ScriptingContainer instance for global use in Embulk.
34
34
  */
35
35
  public static ScriptingContainer setup(
36
- final String[] embulkArgs,
37
36
  final List<String> jrubyOptions,
38
37
  final String bundlePath,
39
38
  final PrintStream warning)
@@ -104,7 +103,16 @@ public class EmbulkGlobalJRubyScriptingContainer
104
103
  //
105
104
  // NOTE: It was written in Ruby as follows:
106
105
  // $LOAD_PATH << File.expand_path('../../', File.dirname(__FILE__))
107
- jrubyGlobalContainer.put("__internal_load_path__", getEmbulkJRubyLoadPath());
106
+ final String jrubyLoadPath;
107
+ try {
108
+ jrubyLoadPath = getEmbulkJRubyLoadPath();
109
+ }
110
+ catch (UnrecognizedJRubyLoadPathException ex) {
111
+ warning.println("[ERROR] Failed to retrieve Embulk's path.");
112
+ ex.printStackTrace(warning);
113
+ throw new RuntimeException(ex);
114
+ }
115
+ jrubyGlobalContainer.put("__internal_load_path__", jrubyLoadPath);
108
116
  jrubyGlobalContainer.runScriptlet("$LOAD_PATH << File.expand_path(__internal_load_path__)");
109
117
  jrubyGlobalContainer.remove("__internal_load_path__");
110
118
 
@@ -114,6 +122,17 @@ public class EmbulkGlobalJRubyScriptingContainer
114
122
 
115
123
  private static final class UnrecognizedJRubyOptionException extends Exception {}
116
124
  private static final class NotWorkingJRubyOptionException extends Exception {}
125
+ private static final class UnrecognizedJRubyLoadPathException extends Exception {
126
+ public UnrecognizedJRubyLoadPathException(final String message)
127
+ {
128
+ super(message);
129
+ }
130
+
131
+ public UnrecognizedJRubyLoadPathException(final String message, final Throwable cause)
132
+ {
133
+ super(message, cause);
134
+ }
135
+ }
117
136
 
118
137
  private static void processJRubyOption(final String jrubyOption, final RubyInstanceConfig jrubyGlobalConfig)
119
138
  throws UnrecognizedJRubyOptionException, NotWorkingJRubyOptionException
@@ -154,26 +173,27 @@ public class EmbulkGlobalJRubyScriptingContainer
154
173
  * "/some/directory"
155
174
  */
156
175
  private static String getEmbulkJRubyLoadPath()
176
+ throws UnrecognizedJRubyLoadPathException
157
177
  {
158
178
  final ProtectionDomain protectionDomain;
159
179
  try {
160
180
  protectionDomain = EmbulkGlobalJRubyScriptingContainer.class.getProtectionDomain();
161
181
  }
162
182
  catch (SecurityException ex) {
163
- throw new EmbulkCommandLineException("Failed to achieve ProtectionDomain", ex);
183
+ throw new UnrecognizedJRubyLoadPathException("Failed to achieve ProtectionDomain", ex);
164
184
  }
165
185
 
166
186
  final CodeSource codeSource = protectionDomain.getCodeSource();
167
187
  if (codeSource == null) {
168
- throw new EmbulkCommandLineException("Failed to achieve CodeSource");
188
+ throw new UnrecognizedJRubyLoadPathException("Failed to achieve CodeSource");
169
189
  }
170
190
 
171
191
  final URL locationUrl = codeSource.getLocation();
172
192
  if (locationUrl == null) {
173
- throw new EmbulkCommandLineException("Failed to achieve location");
193
+ throw new UnrecognizedJRubyLoadPathException("Failed to achieve location");
174
194
  }
175
195
  else if (!locationUrl.getProtocol().equals("file")) {
176
- throw new EmbulkCommandLineException("Invalid location: " + locationUrl.toString());
196
+ throw new UnrecognizedJRubyLoadPathException("Invalid location: " + locationUrl.toString());
177
197
  }
178
198
 
179
199
  final Path locationPath;
@@ -181,7 +201,7 @@ public class EmbulkGlobalJRubyScriptingContainer
181
201
  locationPath = Paths.get(locationUrl.toURI());
182
202
  }
183
203
  catch (URISyntaxException ex) {
184
- throw new EmbulkCommandLineException("Invalid location: " + locationUrl.toString(), ex);
204
+ throw new UnrecognizedJRubyLoadPathException("Invalid location: " + locationUrl.toString(), ex);
185
205
  }
186
206
 
187
207
  if (Files.isDirectory(locationPath)) { // Out of a JAR file
@@ -8,6 +8,7 @@ import java.nio.file.Path;
8
8
  import java.nio.file.Paths;
9
9
  import java.nio.file.StandardOpenOption;
10
10
  import java.util.Collections;
11
+ import java.util.List;
11
12
  import java.util.Map;
12
13
  import java.util.regex.Pattern;
13
14
  import org.embulk.command.PreviewPrinter;
@@ -38,9 +39,19 @@ public class EmbulkRunner
38
39
  {
39
40
  // |EmbulkSetup.setup| initializes:
40
41
  // new EmbulkRunner(embed)
41
- public EmbulkRunner(final EmbulkEmbed embed)
42
+ public EmbulkRunner(final EmbulkEmbed embed,
43
+ final List<String> jrubyOptions,
44
+ final List<String> loadPaths,
45
+ final List<String> pluginPaths,
46
+ final List<String> classpaths,
47
+ final String bundlePath)
42
48
  {
43
49
  this.embed = embed; // org.embulk.EmbulkEmbed
50
+ this.jrubyOptions = jrubyOptions;
51
+ this.loadPaths = loadPaths;
52
+ this.pluginPaths = pluginPaths;
53
+ this.classpaths = classpaths;
54
+ this.bundlePath = bundlePath;
44
55
  }
45
56
 
46
57
  /**
@@ -217,6 +228,9 @@ public class EmbulkRunner
217
228
  private void guessInternal(final ConfigSource configSource, final Path outputPath)
218
229
  throws IOException
219
230
  {
231
+ initializeGlobalJRubyScriptingContainer(
232
+ this.jrubyOptions, this.loadPaths, this.pluginPaths, this.classpaths, this.bundlePath);
233
+
220
234
  try {
221
235
  checkFileWritable(outputPath);
222
236
  }
@@ -239,6 +253,9 @@ public class EmbulkRunner
239
253
  private void previewInternal(final ConfigSource configSource, final String format)
240
254
  throws IOException
241
255
  {
256
+ initializeGlobalJRubyScriptingContainer(
257
+ this.jrubyOptions, this.loadPaths, this.pluginPaths, this.classpaths, this.bundlePath);
258
+
242
259
  final PreviewResult previewResult = this.embed.preview(configSource);
243
260
  final ModelManager modelManager = this.embed.getModelManager();
244
261
 
@@ -266,6 +283,9 @@ public class EmbulkRunner
266
283
  final Path resumeStatePath)
267
284
  throws IOException
268
285
  {
286
+ initializeGlobalJRubyScriptingContainer(
287
+ this.jrubyOptions, this.loadPaths, this.pluginPaths, this.classpaths, this.bundlePath);
288
+
269
289
  try {
270
290
  checkFileWritable(outputPath);
271
291
  }
@@ -397,7 +417,9 @@ public class EmbulkRunner
397
417
  return this.embed.newConfigLoader().fromYamlString(
398
418
  runLiquid(new String(Files.readAllBytes(configFilePath), StandardCharsets.UTF_8),
399
419
  templateParams,
400
- templateIncludePath));
420
+ (templateIncludePath == null
421
+ ? configFilePath.toAbsolutePath().getParent().toString()
422
+ : templateIncludePath)));
401
423
  }
402
424
  else if (EXT_YAML.matcher(configFilePath.toString()).matches()) {
403
425
  return this.embed.newConfigLoader().fromYamlString(
@@ -518,6 +540,49 @@ public class EmbulkRunner
518
540
  // end
519
541
  // end
520
542
 
543
+ // TODO: Check if it is required to process JRuby options.
544
+ private void initializeGlobalJRubyScriptingContainer(
545
+ final List<String> jrubyOptions,
546
+ final List<String> loadPaths,
547
+ final List<String> pluginPaths,
548
+ final List<String> classpaths,
549
+ final String bundlePath)
550
+ {
551
+ final ScriptingContainer globalJRubyContainer =
552
+ EmbulkGlobalJRubyScriptingContainer.setup(jrubyOptions, bundlePath, System.err);
553
+
554
+ // first $LOAD_PATH has highet priority. later load_paths should have highest priority.
555
+ for (final String loadPath : loadPaths) {
556
+ // ruby script directory (use unshift to make it highest priority)
557
+ globalJRubyContainer.put("__internal_load_path__", loadPath);
558
+ globalJRubyContainer.runScriptlet("$LOAD_PATH.unshift File.expand_path(__internal_load_path__)");
559
+ globalJRubyContainer.remove("__internal_load_path__");
560
+ }
561
+
562
+ // # Gem::StubSpecification is an internal API that seems chainging often.
563
+ // # Gem::Specification.add_spec is deprecated also. Therefore, here makes
564
+ // # -L <path> option alias of -I <path>/lib by assuming that *.gemspec file
565
+ // # always has require_paths = ["lib"].
566
+ for (final String pluginPath : pluginPaths) {
567
+ globalJRubyContainer.put("__internal_plugin_path__", pluginPath);
568
+ globalJRubyContainer.runScriptlet("$LOAD_PATH.unshift File.expand_path(File.join(__internal_plugin_path__, 'lib'))");
569
+ globalJRubyContainer.remove("__internal_plugin_path__");
570
+ }
571
+
572
+ for (final String classpath : classpaths) {
573
+ globalJRubyContainer.put("__internal_classpath__", classpath);
574
+ // $CLASSPATH object doesn't have concat method
575
+ globalJRubyContainer.runScriptlet("$CLASSPATH << __internal_classpath__");
576
+ globalJRubyContainer.remove("__internal_classpath__");
577
+ }
578
+
579
+ // see also embulk/java/bootstrap.rb loaded by JRubyScriptingModule
580
+ globalJRubyContainer.runScriptlet("module Embulk; end");
581
+ globalJRubyContainer.put("__internal_embulk_runner_java__", this);
582
+ globalJRubyContainer.runScriptlet("Embulk.const_set :Runner, Embulk::EmbulkRunner.new(__internal_embulk_runner_java__)");
583
+ globalJRubyContainer.remove("__internal_embulk_runner_java__");
584
+ }
585
+
521
586
  // NOTE: The root logger directly from |LoggerFactory|, not from |Exec.getLogger| as it's outside of |Exec.doWith|.
522
587
  private static final Logger rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
523
588
 
@@ -525,4 +590,9 @@ public class EmbulkRunner
525
590
  private final Pattern EXT_YAML_LIQUID = Pattern.compile(".*\\.ya?ml\\.liquid$");
526
591
 
527
592
  private final EmbulkEmbed embed;
593
+ private final List<String> jrubyOptions;
594
+ private final List<String> loadPaths;
595
+ private final List<String> pluginPaths;
596
+ private final List<String> classpaths;
597
+ private final String bundlePath;
528
598
  }
@@ -7,9 +7,6 @@ import java.util.HashMap;
7
7
  import java.util.List;
8
8
  import java.util.Map;
9
9
  import org.embulk.config.ConfigSource;
10
- import org.jruby.embed.LocalContextScope;
11
- import org.jruby.embed.LocalVariableBehavior;
12
- import org.jruby.embed.ScriptingContainer;
13
10
 
14
11
  /**
15
12
  * EmbulkSetup initiates an EmbulkRunner instance. It was originally implemented with Ruby in lib/embulk.rb.
@@ -19,26 +16,13 @@ import org.jruby.embed.ScriptingContainer;
19
16
  */
20
17
  public class EmbulkSetup
21
18
  {
22
- @Deprecated
23
- public static EmbulkRunner setupWithNewScriptingContainer(final Map<String, Object> systemConfigGiven)
24
- {
25
- // The JRuby instance is a global singleton so that the settings here affects later execution.
26
- // The local variable should be persistent so that local variables are set through ScriptingContainer.put.
27
- final ScriptingContainer globalJRubyContainer =
28
- new ScriptingContainer(LocalContextScope.SINGLETON, LocalVariableBehavior.PERSISTENT);
29
- return setup(systemConfigGiven,
30
- Collections.<String>emptyList(),
31
- Collections.<String>emptyList(),
32
- Collections.<String>emptyList(),
33
- globalJRubyContainer);
34
- }
35
-
36
19
  public static EmbulkRunner setup(
20
+ final List<String> jrubyOptions,
37
21
  final Map<String, Object> systemConfigGiven,
38
22
  final List<String> loadPaths,
39
23
  final List<String> pluginPaths,
40
24
  final List<String> classpaths,
41
- final ScriptingContainer globalJRubyContainer)
25
+ final String bundlePath)
42
26
  {
43
27
  // NOTE: When it was in Ruby "require 'json'" was required to format the system config into a JSON string.
44
28
 
@@ -66,49 +50,6 @@ public class EmbulkSetup
66
50
  bootstrap.setSystemConfig(systemConfig);
67
51
  final EmbulkEmbed embed = bootstrap.initialize(); // see embulk-core/src/main/java/org/embulk/jruby/JRubyScriptingModule.
68
52
 
69
- setupLoadPaths(loadPaths, pluginPaths, globalJRubyContainer);
70
- setupClasspaths(classpaths, globalJRubyContainer);
71
-
72
- // see also embulk/java/bootstrap.rb loaded by JRubyScriptingModule
73
- globalJRubyContainer.runScriptlet("module Embulk; end");
74
- globalJRubyContainer.put("__internal_embulk_setup_embed__", embed);
75
- globalJRubyContainer.runScriptlet("Embulk.const_set :Runner, Embulk::EmbulkRunner.new(__internal_embulk_setup_embed__)");
76
- globalJRubyContainer.remove("__internal_embulk_setup_embed__");
77
-
78
- return new EmbulkRunner(embed);
79
- }
80
-
81
- private static void setupLoadPaths(
82
- final List<String> loadPaths,
83
- final List<String> pluginPaths,
84
- final ScriptingContainer globalJRubyContainer)
85
- {
86
- // first $LOAD_PATH has highet priority. later load_paths should have highest priority.
87
- for (final String loadPath : loadPaths) {
88
- // ruby script directory (use unshift to make it highest priority)
89
- globalJRubyContainer.put("__internal_load_path__", loadPath);
90
- globalJRubyContainer.runScriptlet("$LOAD_PATH.unshift File.expand_path(__internal_load_path__)");
91
- globalJRubyContainer.remove("__internal_load_path__");
92
- }
93
-
94
- // # Gem::StubSpecification is an internal API that seems chainging often.
95
- // # Gem::Specification.add_spec is deprecated also. Therefore, here makes
96
- // # -L <path> option alias of -I <path>/lib by assuming that *.gemspec file
97
- // # always has require_paths = ["lib"].
98
- for (final String pluginPath : pluginPaths) {
99
- globalJRubyContainer.put("__internal_plugin_path__", pluginPath);
100
- globalJRubyContainer.runScriptlet("$LOAD_PATH.unshift File.expand_path(File.join(__internal_plugin_path__, 'lib')");
101
- globalJRubyContainer.remove("__internal_plugin_path__");
102
- }
103
- }
104
-
105
- private static void setupClasspaths(final List<String> classpaths, final ScriptingContainer globalJRubyContainer)
106
- {
107
- for (final String classpath : classpaths) {
108
- globalJRubyContainer.put("__internal_classpath__", classpath);
109
- // $CLASSPATH object doesn't have concat method
110
- globalJRubyContainer.runScriptlet("$CLASSPATH << __internal_classpath__");
111
- globalJRubyContainer.remove("__internal_classpath__");
112
- }
53
+ return new EmbulkRunner(embed, jrubyOptions, loadPaths, pluginPaths, classpaths, bundlePath);
113
54
  }
114
55
  }
@@ -203,8 +203,9 @@ public class ExecSession
203
203
  {
204
204
  ConfigSource config = Exec.newConfigSource();
205
205
  config.set("timezone", timezone.getID());
206
+ // TODO: Stop creating the |FormatterTask| as |TimestampFormater.FormatterTask| is deprecated since v0.6.14.
206
207
  FormatterTask formatterTask = config.loadConfig(FormatterTask.class);
207
- return new TimestampFormatter(format, formatterTask);
208
+ return new TimestampFormatter(format, formatterTask.getTimeZone());
208
209
  }
209
210
 
210
211
  public TempFileSpace getTempFileSpace()
@@ -26,13 +26,13 @@ public class TimestampFormat
26
26
  @Deprecated
27
27
  public TimestampFormatter newFormatter(TimestampFormatter.FormatterTask task)
28
28
  {
29
- return new TimestampFormatter(format, task);
29
+ return new TimestampFormatter(format, task.getTimeZone());
30
30
  }
31
31
 
32
32
  @Deprecated
33
33
  public TimestampParser newParser(TimestampParser.ParserTask task)
34
34
  {
35
- return new TimestampParser(format, task);
35
+ return new TimestampParser(format, task.getDefaultTimeZone());
36
36
  }
37
37
 
38
38
  private static Set<String> availableTimeZoneNames = ImmutableSet.copyOf(DateTimeZone.getAvailableIDs());
@@ -16,6 +16,7 @@ public class PagePrinter
16
16
  private final TimestampFormatter[] timestampFormatters;
17
17
  private final ArrayList<String> record;
18
18
 
19
+ // TODO: Update this constructor because |TimestampFormater.FormatterTask| is deprecated since v0.6.14.
19
20
  public PagePrinter(Schema schema, TimestampFormatter.FormatterTask task)
20
21
  {
21
22
  this.schema = schema;
@@ -23,7 +24,7 @@ public class PagePrinter
23
24
  for (int i=0; i < timestampFormatters.length; i++) {
24
25
  if (schema.getColumnType(i) instanceof TimestampType) {
25
26
  TimestampType type = (TimestampType) schema.getColumnType(i);
26
- timestampFormatters[i] = new TimestampFormatter(type.getFormat(), task);
27
+ timestampFormatters[i] = new TimestampFormatter(type.getFormat(), task.getTimeZone());
27
28
  }
28
29
  }
29
30
 
@@ -4,6 +4,7 @@ Release Notes
4
4
  .. toctree::
5
5
  :maxdepth: 1
6
6
 
7
+ release/release-0.8.30
7
8
  release/release-0.8.29
8
9
  release/release-0.8.28
9
10
  release/release-0.8.27
@@ -0,0 +1,14 @@
1
+ Release 0.8.30
2
+ ==================================
3
+
4
+ General Changes
5
+ ------------------
6
+
7
+ * Fix -L option syntax error [#759]
8
+ * Make Liquid's "include" work again [#757] [#761]
9
+ * Avoid calling deprecated constructors and using `TimestampFormatter.FormatterTask` [#760] [#762] [#763]
10
+ * Some refactoring [#755]
11
+
12
+ Release Date
13
+ ------------------
14
+ 2017-08-23
@@ -63,6 +63,13 @@ module Embulk
63
63
 
64
64
  require_classpath(true)
65
65
 
66
- Java::org.embulk.EmbulkSetup::setupWithNewScriptingContainer(Java::java.util.HashMap.new(system_config))
66
+ Java::org.embulk.EmbulkSetup::setup(
67
+ Java::java.util.ArrayList.new(),
68
+ Java::java.util.HashMap.new(system_config),
69
+ Java::java.util.ArrayList.new(),
70
+ Java::java.util.ArrayList.new(),
71
+ Java::java.util.ArrayList.new(),
72
+ nil
73
+ )
67
74
  end
68
75
  end
@@ -1,23 +1,19 @@
1
1
  module Embulk
2
2
 
3
- # Embulk.setup initializes:
4
- # Runner = EmbulkRunner.new
5
-
6
3
  class EmbulkRunner
7
- def initialize(embed)
8
- @embed = embed # org.embulk.EmbulkEmbed
4
+ def initialize(runner_java)
5
+ @runner_java = runner_java # Java::org.embulk.EmbulkRunner
9
6
  end
10
7
 
11
8
  def guess(config, options={})
12
9
  output_path =
13
10
  (options[:next_config_output_path] ? Java::java.lang.String.new(options[:next_config_output_path]) : nil)
14
- embulk_runner_java = Java::org.embulk.EmbulkRunner.new(@embed)
15
11
 
16
12
  case config
17
13
  when String
18
- embulk_runner_java.guess(Java::java.lang.String.new(config), output_path)
14
+ @runner_java.guess(Java::java.lang.String.new(config), output_path)
19
15
  when Hash, DataSource
20
- embulk_runner_java.guess(DataSource.new(config).to_java, output_path)
16
+ @runner_java.guess(DataSource.new(config).to_java, output_path)
21
17
  end
22
18
 
23
19
  nil
@@ -25,13 +21,12 @@ module Embulk
25
21
 
26
22
  def preview(config, options={})
27
23
  format = (options[:format] ? Java::java.lang.String.new(options[:format]) : nil)
28
- embulk_runner_java = Java::org.embulk.EmbulkRunner.new(@embed)
29
24
 
30
25
  case config
31
26
  when String
32
- embulk_runner_java.preview(Java::java.lang.String.new(config), format)
27
+ @runner_java.preview(Java::java.lang.String.new(config), format)
33
28
  when Hash, DataSource
34
- embulk_runner_java.preview(DataSource.new(config).to_java, format)
29
+ @runner_java.preview(DataSource.new(config).to_java, format)
35
30
  end
36
31
 
37
32
  nil
@@ -44,13 +39,12 @@ module Embulk
44
39
  (options[:next_config_output_path] ? Java::java.lang.String.new(options[:next_config_output_path]) : nil)
45
40
  resume_state_path =
46
41
  (options[:resume_state_path] ? Java::java.lang.String.new(options[:resume_state_path]) : nil)
47
- embulk_runner_java = Java::org.embulk.EmbulkRunner.new(@embed)
48
42
 
49
43
  case config
50
44
  when String
51
- embulk_runner_java.run(Java::java.lang.String.new(config), config_diff_path, output_path, resume_state_path)
45
+ @runner_java.run(Java::java.lang.String.new(config), config_diff_path, output_path, resume_state_path)
52
46
  when Hash, DataSource
53
- embulk_runner_java.run(DataSource.new(config).to_java, config_diff_path, output_path, resume_state_path)
47
+ @runner_java.run(DataSource.new(config).to_java, config_diff_path, output_path, resume_state_path)
54
48
  end
55
49
 
56
50
  nil
@@ -3,7 +3,7 @@
3
3
  module Embulk
4
4
  @@warned = false
5
5
 
6
- VERSION_INTERNAL = '0.8.29'
6
+ VERSION_INTERNAL = '0.8.30'
7
7
 
8
8
  DEPRECATED_MESSAGE = 'Embulk::VERSION in (J)Ruby is deprecated. Use org.embulk.EmbulkVersion::VERSION instead. If this message is from a plugin, please tell this to the author of the plugin!'
9
9
  def self.const_missing(name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.29
4
+ version: 0.8.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-02 00:00:00.000000000 Z
11
+ date: 2017-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jruby-jars
@@ -115,10 +115,10 @@ files:
115
115
  - classpath/commons-compress-1.10.jar
116
116
  - classpath/commons-lang-2.4.jar
117
117
  - classpath/commons-lang3-3.4.jar
118
- - classpath/embulk-cli-0.8.29.jar
119
- - classpath/embulk-core-0.8.29.jar
120
- - classpath/embulk-jruby-strptime-0.8.29.jar
121
- - classpath/embulk-standards-0.8.29.jar
118
+ - classpath/embulk-cli-0.8.30.jar
119
+ - classpath/embulk-core-0.8.30.jar
120
+ - classpath/embulk-jruby-strptime-0.8.30.jar
121
+ - classpath/embulk-standards-0.8.30.jar
122
122
  - classpath/guava-18.0.jar
123
123
  - classpath/guice-4.0.jar
124
124
  - classpath/guice-bootstrap-0.1.1.jar
@@ -154,11 +154,9 @@ files:
154
154
  - embulk-cli/build.gradle
155
155
  - embulk-cli/src/main/bat/selfrun.bat.template
156
156
  - embulk-cli/src/main/java/org/embulk/cli/EmbulkArguments.java
157
- - embulk-cli/src/main/java/org/embulk/cli/EmbulkBundle.java
158
157
  - embulk-cli/src/main/java/org/embulk/cli/EmbulkCommandLine.java
159
158
  - embulk-cli/src/main/java/org/embulk/cli/EmbulkCommandLineException.java
160
159
  - embulk-cli/src/main/java/org/embulk/cli/EmbulkExample.java
161
- - embulk-cli/src/main/java/org/embulk/cli/EmbulkGlobalJRubyScriptingContainer.java
162
160
  - embulk-cli/src/main/java/org/embulk/cli/EmbulkMigrate.java
163
161
  - embulk-cli/src/main/java/org/embulk/cli/EmbulkNew.java
164
162
  - embulk-cli/src/main/java/org/embulk/cli/EmbulkRun.java
@@ -180,6 +178,7 @@ files:
180
178
  - embulk-cli/src/test/java/org/embulk/cli/SelfrunTest.java
181
179
  - embulk-core/build.gradle
182
180
  - embulk-core/src/main/java/org/embulk/EmbulkEmbed.java
181
+ - embulk-core/src/main/java/org/embulk/EmbulkGlobalJRubyScriptingContainer.java
183
182
  - embulk-core/src/main/java/org/embulk/EmbulkRunner.java
184
183
  - embulk-core/src/main/java/org/embulk/EmbulkService.java
185
184
  - embulk-core/src/main/java/org/embulk/EmbulkSetup.java
@@ -520,6 +519,7 @@ files:
520
519
  - embulk-docs/src/release/release-0.8.28.rst
521
520
  - embulk-docs/src/release/release-0.8.29.rst
522
521
  - embulk-docs/src/release/release-0.8.3.rst
522
+ - embulk-docs/src/release/release-0.8.30.rst
523
523
  - embulk-docs/src/release/release-0.8.4.rst
524
524
  - embulk-docs/src/release/release-0.8.5.rst
525
525
  - embulk-docs/src/release/release-0.8.6.rst
@@ -1,44 +0,0 @@
1
- package org.embulk.cli;
2
-
3
- import java.util.Arrays;
4
- import java.util.Collections;
5
- import java.util.List;
6
- import org.embulk.EmbulkVersion;
7
- import org.jruby.embed.ScriptingContainer;
8
-
9
- public class EmbulkBundle
10
- {
11
- public static void checkBundle(
12
- final String[] embulkArgs,
13
- final List<String> jrubyOptions)
14
- {
15
- checkBundleWithEmbulkVersion(embulkArgs, jrubyOptions, EmbulkVersion.VERSION);
16
- }
17
-
18
- // It accepts |embulkVersion| so that it can receive Embulk's version from Ruby (bin/embulk).
19
- public static void checkBundleWithEmbulkVersion(
20
- final String[] embulkArgs,
21
- final List<String> jrubyOptions,
22
- final String embulkVersion)
23
- {
24
- final String bundlePath = System.getenv("EMBULK_BUNDLE_PATH");
25
-
26
- final ScriptingContainer globalJRubyContainer =
27
- EmbulkGlobalJRubyScriptingContainer.setup(embulkArgs, jrubyOptions, bundlePath, System.err);
28
-
29
- // NOTE: It was written in Ruby as follows in case |bundlePath| != null:
30
- // begin
31
- // require 'embulk/command/embulk_main'
32
- // rescue LoadError
33
- // $LOAD_PATH << File.expand_path('../../', File.dirname(__FILE__))
34
- // require 'embulk/command/embulk_main'
35
- // end
36
- //
37
- // NOTE: It was written in Ruby as follows in case |bundlePath| == null::
38
- // require 'embulk/command/embulk_main'
39
- //
40
- // TODO: Consider handling LoadError or similar errors.
41
- final EmbulkRun runner = new EmbulkRun(embulkVersion, globalJRubyContainer);
42
- runner.run(Collections.unmodifiableList(Arrays.asList(embulkArgs)), jrubyOptions);
43
- }
44
- }