if (target == null || (target.exists() && !target.isDirectory())) {
throw new IOException("Must specify target directory, where to generate Gem!");
}
final Gem gem = new Gem(gemspec);
if (artifact.getArtifactFile() != null) {
gem.addFile(artifact.getArtifactFile(), createLibFileName(artifact,
".jar"));
}
// create "meta" ruby file
final String rubyStubMetaPath = createLibFileName(artifact,
"-maven.rb");
final File rubyStubMetaFile = generateRubyMetaStub(gemspec, artifact);
gem.addFile(rubyStubMetaFile, rubyStubMetaPath);
// create runtime ruby file
final String rubyStubPath = createLibFileName(artifact, ".rb");
// System.err.println( rubyStubPath );
final File rubyStubFile = generateRubyStub(gemspec,
artifact,
RubyDependencyType.RUNTIME);
gem.addFile(rubyStubFile, rubyStubPath);
// create development ruby file
final String rubyDevelopmentStubPath = createLibFileName(artifact,
"-dev.rb");
final File rubyDevelopmentStubFile = generateRubyStub(gemspec,
artifact,
RubyDependencyType.DEVELOPMENT);
gem.addFile(rubyDevelopmentStubFile, rubyDevelopmentStubPath);
final File rubyMainStubFile = generateMainStub(artifact);
gem.addFile(rubyMainStubFile, LIB_PATH + gemspec.getName() + ".rb" );
// write file
final File gemfile = this.gemPackager.createGem(gem, target);
return new GemArtifact(gemspec, gemfile);