tetra 0.41.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -23,5 +23,5 @@ _yardoc
23
23
  doc/
24
24
 
25
25
  # integration test files
26
- integration-tests/commons
26
+ integration-tests/commons-collections
27
27
 
data/README.md CHANGED
@@ -35,33 +35,34 @@ With `tetra` you are not building all dependencies from source, just your packag
35
35
 
36
36
  ## A commons-collections walkthrough
37
37
 
38
- First, ceate a new `tetra` project, in this example named "myproject":
38
+ First, ceate a new `tetra` project named after the package that we want to build:
39
39
 
40
- mkdir myproject
41
- cd myproject
40
+ mkdir commons-collections
41
+ cd commons-collections
42
42
  tetra init
43
43
 
44
- Second, place commons-collections source files in the `src/` folder. Specifically, every `src/` subfolder will become a separate package named after the folder itself, so you can use the following:
44
+ Second, place source files in the `src/` folder:
45
45
 
46
46
  cd src
47
- mkdir commons-collections
48
- cd commons-collections
49
47
  wget http://archive.apache.org/dist/commons/collections/source/commons-collections-3.2.1-src.zip
50
48
  unzip commons-collections-3.2.1-src.zip
51
49
  rm commons-collections-3.2.1-src.zip
52
50
 
53
51
  Third, put all non-source files needed for the build in `kit/`. This means all build dependencies and tools excluding the JDK: in this case it is just Maven:
54
52
 
55
- cd ../../kit
53
+ cd ../kit
56
54
  wget http://www.eu.apache.org/dist/maven/binaries/apache-maven-3.1.1-bin.zip
57
55
  unzip apache-maven-3.1.1-bin.zip
58
56
  rm apache-maven-3.1.1-bin.zip
59
57
 
60
58
  Fourth, you need to show `tetra` how to build your package by running appropriate commands between `tetra dry-run` and `tetra finish`. Bash history will be recorded to generate a "starting-point" build script (that will be sufficient in simple cases like this):
61
59
 
62
- cd ../src/commons-collections/commons-collections-3.2.1-src/
60
+ cd ../src
63
61
  tetra dry-run
62
+
63
+ cd commons-collections-3.2.1-src/
64
64
  tetra mvn package
65
+
65
66
  tetra finish
66
67
 
67
68
  Note that we used `tetra mvn package` instead of `mvn package`: this will use of the Maven copy we put in `kit/` and the repository in `kit/m2`.
data/SPECIAL_CASES.md CHANGED
@@ -10,9 +10,9 @@ You can do any manual changes to spec and build.sh files and regenerate them lat
10
10
 
11
11
  * `tetra generate-kit-archive`: (re)generates the kit tarball;
12
12
  * `tetra generate-kit-spec`: (re)generates the kit spec;
13
- * `tetra generate-package-script`: (re)generates the `build.sh` file from the latest bash history (assumes `tetra dry-run` and `tetra finish`have been used). Assumes your current working directory is in a package folder (that is, a subdirectory of `src/<package name>/`);
14
- * `tetra generate-package-archive`: (re)generates a package tarball;
15
- * `tetra generate-package-spec`: (re)generates a package spec;
13
+ * `tetra generate-package-script`: (re)generates the `build.sh` file from the latest bash history (assumes `tetra dry-run` and `tetra finish`have been used);
14
+ * `tetra generate-package-archive`: (re)generates the package tarball;
15
+ * `tetra generate-package-spec`: (re)generates the package spec;
16
16
 
17
17
  ## Kit sources
18
18
 
@@ -36,6 +36,12 @@ You can also use:
36
36
 
37
37
  To get a list of jars that have one or more `.class` file which does not have a corresponding `.java` file in `kit/` (or zip files in `kit/`).
38
38
 
39
+ ## Replacing kit packages
40
+
41
+ After you built a package, you might want to use it instead of some binary packages to build other ones.
42
+
43
+ `tetra` automatically creates some of the needed instructions inside of the spec file, you need to uncomment them and edit them manually to be fully functional.
44
+
39
45
  ## Ant builds
40
46
 
41
47
  `tetra` is currently optimized for Maven as it is the most common build tool, but it can work with any other. In particular, support for Ant has already been implemented and `tetra ant` works like `tetra mvn`.
@@ -2,55 +2,21 @@
2
2
 
3
3
  # A crude integration test that builds some Apache Commons libraries
4
4
 
5
- set -e
5
+ set -ex
6
6
 
7
- rm -Rf commons
8
- mkdir commons
9
- cd commons
10
- tetra init
11
-
12
- cd src
7
+ rm -Rf commons-collections
13
8
  mkdir commons-collections
14
9
  cd commons-collections
15
- wget http://archive.apache.org/dist/commons/collections/source/commons-collections-3.2.1-src.zip
16
- unzip commons-collections-3.2.1-src.zip
17
- rm commons-collections-3.2.1-src.zip
18
-
19
- cd ../../kit
20
- wget http://apache.fastbull.org/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.zip
21
- unzip apache-maven-*.zip
22
- rm apache-maven-*.zip
23
- cd ..
24
-
25
- tetra dry-run --very-very-verbose
26
- cd src/commons-collections/commons-collections-3.2.1-src/
27
- tetra mvn package -DskipTests
28
- tetra finish
29
-
30
- tetra generate-kit-archive
31
- tetra generate-kit-spec
32
- tetra generate-package-archive
33
- tetra generate-package-spec
34
- # simulate tetra generate-package-script
35
- cat >../../../output/commons-collections/build.sh <<"EOF"
36
- #!/bin/bash
37
- PROJECT_PREFIX=`readlink -e .`
38
- cd .
39
- cd src/commons-collections/commons-collections-3.2.1-src/
40
- $PROJECT_PREFIX/kit/apache-maven-3.1.1/bin/mvn -Dmaven.repo.local=$PROJECT_PREFIX/kit/m2 -s$PROJECT_PREFIX/kit/m2/settings.xml -o package -DskipTests
41
- EOF
10
+ tetra init
42
11
 
43
- cd ../../..
12
+ cd kit
13
+ unzip ../../apache-maven-3.1.1-bin.zip
44
14
 
45
- cd src
46
- mkdir commons-fileupload
47
- cd commons-fileupload
48
- wget http://archive.apache.org/dist/commons/fileupload/source/commons-fileupload-1.3-src.zip
49
- unzip commons-fileupload-1.3-src.zip
50
- rm commons-fileupload-1.3-src.zip
15
+ cd ../src
16
+ unzip ../../commons-collections-3.2.1-src.zip
51
17
 
52
- tetra dry-run
53
- cd commons-fileupload-1.3-src/
18
+ tetra dry-run --very-very-verbose
19
+ cd commons-collections-3.2.1-src/
54
20
  tetra mvn package -DskipTests
55
21
  tetra finish
56
22
 
@@ -59,17 +25,15 @@ tetra generate-kit-spec
59
25
  tetra generate-package-archive
60
26
  tetra generate-package-spec
61
27
  # simulate tetra generate-package-script
62
- cat >../../../output/commons-fileupload/build.sh <<"EOF"
28
+ cd ../..
29
+ cat >src/build.sh <<"EOF"
63
30
  #!/bin/bash
64
31
  PROJECT_PREFIX=`readlink -e .`
65
32
  cd .
66
- cd src/commons-fileupload/commons-fileupload-1.3-src/
33
+ cd src/commons-collections-3.2.1-src/
67
34
  $PROJECT_PREFIX/kit/apache-maven-3.1.1/bin/mvn -Dmaven.repo.local=$PROJECT_PREFIX/kit/m2 -s$PROJECT_PREFIX/kit/m2/settings.xml -o package -DskipTests
68
35
  EOF
69
36
 
70
- cd ../../..
71
-
72
-
73
37
  echo "**************** All Done ****************"
74
38
 
75
- ls -lah output/*
39
+ ls -lah *
@@ -1,8 +1,8 @@
1
- This directory contains all binary files needed to build a tetra project's
2
- packages.
1
+ This directory contains all binary files needed to build software in src/.
3
2
 
4
- These files should only be used during build and should not be installed
5
- on users' systems.
3
+ These files will be packaged as binary and will only be used at build time.
4
+ They will not be installed on users' systems.
6
5
 
7
- Some generally useful configuration files are also placed here (eg.
8
- m2/settings.xml for Maven builds).
6
+ - jars/ contains simple jars that will be packaged singularly
7
+ - m2/ contains a Maven repo which artifacts will be packaged singularly
8
+ - everything else will be packaged in one "glue" package.
@@ -1 +1,3 @@
1
- This directory contains jars moved here from source archives.
1
+ This directory contains binary files needed to build software in src/.
2
+
3
+ Only jar files not in m2/ should be placed here.
@@ -37,6 +37,9 @@ Requires: java
37
37
  Requires: mvn(<%= dependency_id[0] %>:<%= dependency_id[1] %>) <% if dependency_id[3] != nil %>==<%= dependency_id[3] %><% end %>
38
38
  <% end %>
39
39
 
40
+ # to use this package in other tetra builds, uncomment the following
41
+ #Provides: tetra-mvn(<%= group_id %>:<%= artifact_id %>) == <%= version %>
42
+
40
43
  %description
41
44
  <%=
42
45
  description
@@ -58,6 +61,14 @@ mkdir -p %{buildroot}%{_javadir}
58
61
  cp -a <%= output %> %{buildroot}%{_javadir}/<%= File.basename(output) %>
59
62
  <% end %>
60
63
 
64
+ # to use this package in other tetra builds, uncomment and edit appropriately
65
+ #%define _kitdir %{_datadir}/tetra/m2/<%= group_id.gsub(".", "/") %>/<%= artifact_id %>/<%= version %>
66
+ #mkdir -p %_kitdir
67
+ <% outputs.each do |output| %>
68
+ #ln -s %{buildroot}%{_javadir}/<%= File.basename(output) %> %_kitdir
69
+ <% end %>
70
+ #ln -s <pomfile> %_kitdir
71
+
61
72
  %files
62
73
  %defattr(-,root,root)
63
74
  <% outputs.each do |output| %>
@@ -1,6 +1,3 @@
1
- For each package you want to create, you should create a subdirectory here
2
- named after the package name itself.
3
-
4
- In that directory, place all the source files "verbatim" (as checked out from
5
- the original source repository, ideally in a different subdirectory)
6
- plus any additional files you might need for the build.
1
+ All "verbatim" source files should be placed here (as checked out from
2
+ the original source repository), together with any additional files you
3
+ might need for the build.
@@ -78,8 +78,6 @@ module Tetra
78
78
  $stderr.puts e
79
79
  rescue NoProjectDirectoryError => e
80
80
  $stderr.puts "#{e.directory} is not a tetra project directory, see tetra init"
81
- rescue NoPackageDirectoryError => e
82
- $stderr.puts "#{e.directory} is not a tetra package directory, see README"
83
81
  rescue GitAlreadyInitedError
84
82
  $stderr.puts "This directory is already a tetra project"
85
83
  rescue ExecutableNotFoundError => e
@@ -3,7 +3,7 @@
3
3
  module Tetra
4
4
  # tetra finish
5
5
  class FinishCommand < Tetra::BaseCommand
6
- option %w(-a --abort), :flag, "build abort, restore files as before dry-run"
6
+ option %w(-a --abort), :flag, "abort build, restore files as before dry-run"
7
7
 
8
8
  def execute
9
9
  checking_exceptions do
@@ -4,7 +4,6 @@ module Tetra
4
4
  # tetra generate-all
5
5
  class GenerateAllCommand < Tetra::BaseCommand
6
6
  option %w(-f --filter), "FILTER", "filter files to be installed by this package spec", default: "*.jar"
7
- parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", default: "."
8
7
  parameter "[POM]", "a package pom file path", default: "pom.xml"
9
8
 
10
9
  def execute
@@ -16,16 +15,13 @@ module Tetra
16
15
  GenerateKitSpecCommand.new(@invocation_path).execute
17
16
 
18
17
  script_command = GeneratePackageScriptCommand.new(@invocation_path)
19
- script_command.directory = directory
20
18
  script_command.execute
21
19
 
22
20
  archive_command = GeneratePackageArchiveCommand.new(@invocation_path)
23
- archive_command.directory = directory
24
21
  archive_command.execute
25
22
 
26
23
  archive_command = GeneratePackageSpecCommand.new(@invocation_path)
27
24
  archive_command.filter = filter
28
- archive_command.directory = directory
29
25
  archive_command.pom = pom
30
26
  archive_command.execute
31
27
  end
@@ -3,14 +3,11 @@
3
3
  module Tetra
4
4
  # tetra generate-package-archive
5
5
  class GeneratePackageArchiveCommand < Tetra::BaseCommand
6
- parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", default: "."
7
-
8
6
  def execute
9
7
  checking_exceptions do
10
8
  project = Tetra::Project.new(".")
11
9
  ensure_dry_running(false, project) do
12
- package_name = project.get_package_name(directory)
13
- result_path = Tetra::Package.new(project, package_name).to_archive
10
+ result_path = Tetra::Package.new(project).to_archive
14
11
  print_generation_result(project, result_path)
15
12
  end
16
13
  end
@@ -3,16 +3,13 @@
3
3
  module Tetra
4
4
  # tetra generate-package-script
5
5
  class GeneratePackageScriptCommand < Tetra::BaseCommand
6
- parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", default: "."
7
-
8
6
  def execute
9
7
  checking_exceptions do
10
8
  project = Tetra::Project.new(".")
11
9
  ensure_dry_running(false, project) do
12
- package_name = project.get_package_name(directory)
13
10
  history_file = File.join(Dir.home, ".bash_history")
14
11
  result_path, conflict_count = Tetra::ScriptGenerator.new(project, history_file)
15
- .generate_build_script(package_name)
12
+ .generate_build_script
16
13
  print_generation_result(project, result_path, conflict_count)
17
14
  end
18
15
  end
@@ -4,16 +4,14 @@ module Tetra
4
4
  # tetra generate-package-spec
5
5
  class GeneratePackageSpecCommand < Tetra::BaseCommand
6
6
  option %w(-f --filter), "FILTER", "filter files to be installed by this spec", default: "*.jar"
7
- parameter "[DIRECTORY]", "path to a package directory (src/<package name>)", default: "."
8
7
  parameter "[POM]", "a pom file path", default: "pom.xml"
9
8
 
10
9
  def execute
11
10
  checking_exceptions do
12
11
  project = Tetra::Project.new(".")
13
12
  ensure_dry_running(false, project) do
14
- package_name = project.get_package_name(directory)
15
13
  result_path, conflict_count =
16
- Tetra::Package.new(project, package_name, pom, filter).to_spec
14
+ Tetra::Package.new(project, pom, filter).to_spec
17
15
  print_generation_result(project, result_path, conflict_count)
18
16
  end
19
17
  end
@@ -7,7 +7,7 @@ module Tetra
7
7
  checking_exceptions do
8
8
  Tetra::Project.init(".")
9
9
  puts "Project inited."
10
- puts "Add sources to src/<package name>, binary dependencies to kit/."
10
+ puts "Add sources to src/, binary dependencies to kit/."
11
11
  puts "When you are ready to test a build, use \"tetra dry-run\"."
12
12
  end
13
13
  end
data/lib/tetra/main.rb CHANGED
@@ -35,37 +35,37 @@ module Tetra
35
35
 
36
36
  subcommand(
37
37
  "generate-kit-archive",
38
- "Create or refresh the kit tarball",
38
+ "Create or refresh the kit tarballs",
39
39
  Tetra::GenerateKitArchiveCommand
40
40
  )
41
41
 
42
42
  subcommand(
43
43
  "generate-kit-spec",
44
- "Create or refresh a spec file for the kit",
44
+ "Create or refresh the kit spec files",
45
45
  Tetra::GenerateKitSpecCommand
46
46
  )
47
47
 
48
48
  subcommand(
49
49
  "generate-package-script",
50
- "Create or refresh a build.sh file for a package",
50
+ "Create or refresh the package build.sh file",
51
51
  Tetra::GeneratePackageScriptCommand
52
52
  )
53
53
 
54
54
  subcommand(
55
55
  "generate-package-archive",
56
- "Create or refresh a package tarball",
56
+ "Create or refresh the package tarball",
57
57
  Tetra::GeneratePackageArchiveCommand
58
58
  )
59
59
 
60
60
  subcommand(
61
61
  "generate-package-spec",
62
- "Create or refresh a spec file for a package",
62
+ "Create or refresh the package spec file",
63
63
  Tetra::GeneratePackageSpecCommand
64
64
  )
65
65
 
66
66
  subcommand(
67
67
  "generate-all",
68
- "Create or refresh specs, archives, scripts for a package and the kit",
68
+ "Create or refresh all specs, archives, scripts",
69
69
  Tetra::GenerateAllCommand
70
70
  )
71
71
 
data/lib/tetra/package.rb CHANGED
@@ -1,15 +1,12 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Tetra
4
- # represents a Java project package in Tetra, corresponding to a directory
5
- # in src/
4
+ # represents a Java project packaged in Tetra
6
5
  class Package
7
6
  extend Forwardable
8
7
  include SpecGenerator
9
8
 
10
- attr_reader :name
11
-
12
- def_delegator :@project, :name, :project_name
9
+ def_delegator :@project, :name, :name
13
10
 
14
11
  def_delegator :@kit, :items, :kit_items
15
12
 
@@ -20,20 +17,24 @@ module Tetra
20
17
  def_delegator :@pom, :version
21
18
  def_delegator :@pom, :runtime_dependency_ids
22
19
 
20
+ # implement to_spec
21
+ attr_reader :spec_dir
22
+
23
23
  # implement to_archive
24
24
  include Archiver
25
25
  attr_reader :source_dir
26
26
  attr_reader :source_paths
27
27
  attr_reader :destination_dir
28
28
 
29
- def initialize(project, name, pom_path = nil, filter = nil)
29
+ def initialize(project, pom_path = nil, filter = nil)
30
30
  @project = project
31
31
  @kit = Tetra::Kit.new(project)
32
- @name = name
33
32
  @pom = pom_path.nil? ? nil : Tetra::Pom.new(pom_path)
34
33
  @filter = filter
35
34
 
36
- @source_dir = File.join("src", name)
35
+ @spec_dir = "src"
36
+
37
+ @source_dir = "src"
37
38
  @source_paths = ["*"]
38
39
  @destination_dir = name
39
40
  end
@@ -50,7 +51,7 @@ module Tetra
50
51
 
51
52
  # files produced by this package
52
53
  def outputs
53
- @project.get_produced_files(@name).select do |file|
54
+ @project.produced_files.select do |file|
54
55
  File.fnmatch?(@filter, File.basename(file))
55
56
  end
56
57
  end
@@ -71,10 +72,6 @@ module Tetra
71
72
  name
72
73
  end
73
74
 
74
- def spec_dir
75
- File.join("src", name)
76
- end
77
-
78
75
  def template_spec_name
79
76
  "package.spec"
80
77
  end
data/lib/tetra/project.rb CHANGED
@@ -40,22 +40,6 @@ module Tetra
40
40
  File.directory?(File.join(dir, ".git"))
41
41
  end
42
42
 
43
- # returns the package name corresponding to the specified dir, if any
44
- # raises NoPackageDirectoryError if dir is not a (sub)directory of a package
45
- def get_package_name(dir)
46
- dir_path = Pathname.new(File.expand_path(dir)).relative_path_from(Pathname.new(@full_path))
47
- components = dir_path.to_s.split(File::SEPARATOR)
48
- if components.count >= 2 &&
49
- components.first == "src" &&
50
- Dir.exist?(File.join(@full_path, components[0], components[1]))
51
- components[1]
52
- else
53
- fail NoPackageDirectoryError
54
- end
55
- rescue ArgumentError, NoProjectDirectoryError
56
- raise NoPackageDirectoryError, dir
57
- end
58
-
59
43
  # inits a new project directory structure
60
44
  def self.init(dir)
61
45
  Dir.chdir(dir) do
@@ -188,19 +172,18 @@ module Tetra
188
172
  @git.get_message(latest_tag(:dry_run_started))
189
173
  end
190
174
 
191
- # returns a list of files produced during dry-runs in a certain package
192
- def get_produced_files(package)
175
+ # returns a list of files produced during dry-runs
176
+ def produced_files
193
177
  dry_run_count = latest_tag_count(:dry_run_changed)
194
178
  log.debug "Getting produced files from #{dry_run_count} dry runs"
195
179
  if dry_run_count >= 1
196
- package_dir = File.join("src", package)
197
180
  (1..dry_run_count).map do |i|
198
- @git.changed_files_between("dry_run_started_#{i}", "dry_run_changed_#{i}", package_dir)
181
+ @git.changed_files_between("dry_run_started_#{i}", "dry_run_changed_#{i}", "src")
199
182
  end
200
183
  .flatten
201
184
  .uniq
202
185
  .sort
203
- .map { |file| Pathname.new(file).relative_path_from(Pathname.new(package_dir)).to_s }
186
+ .map { |file| Pathname.new(file).relative_path_from(Pathname.new("src")).to_s }
204
187
  else
205
188
  []
206
189
  end
@@ -12,7 +12,7 @@ module Tetra
12
12
  @history_path = history_path
13
13
  end
14
14
 
15
- def generate_build_script(name)
15
+ def generate_build_script
16
16
  @project.from_directory do
17
17
  history_lines = File.readlines(@history_path).map { |e| e.strip }
18
18
  relevant_lines =
@@ -40,14 +40,11 @@ module Tetra
40
40
 
41
41
  new_content = script_lines.join("\n") + "\n"
42
42
 
43
- script_name = "build.sh"
44
- result_path = File.join("src", name, script_name)
43
+ result_path = File.join("src", "build.sh")
45
44
  conflict_count = @project.merge_new_content(new_content, result_path, "Build script generated",
46
- "generate_#{name}_build_script")
45
+ "generate_build_script")
47
46
 
48
- destination_dir = File.join("output", name)
49
- FileUtils.mkdir_p(destination_dir)
50
- destination_script_path = File.join(destination_dir, script_name)
47
+ destination_script_path = File.join("output", @project.name, "build.sh")
51
48
  FileUtils.symlink(File.expand_path(result_path), destination_script_path, force: true)
52
49
 
53
50
  [result_path, conflict_count]
data/lib/tetra/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  # base module for tetra
4
4
  module Tetra
5
- VERSION = "0.41.0"
5
+ VERSION = "0.42.0"
6
6
  end
@@ -3,13 +3,10 @@
3
3
  require "spec_helper"
4
4
 
5
5
  describe Tetra::Package do
6
- before(:each) do
7
- @project_path = File.join("spec", "data", "test-project")
8
- Dir.mkdir(@project_path)
9
-
10
- Tetra::Project.init(@project_path)
11
- @project = Tetra::Project.new(@project_path)
6
+ include Tetra::Mockers
12
7
 
8
+ before(:each) do
9
+ create_mock_project
13
10
  @project.dry_run
14
11
  Dir.chdir(@project_path) do
15
12
  FileUtils.touch(File.join("kit", "jars", "test.jar"))
@@ -17,18 +14,18 @@ describe Tetra::Package do
17
14
  @project.finish(false)
18
15
 
19
16
  @project.from_directory do
20
- FileUtils.mkdir_p File.join("src", "test", "out")
17
+ FileUtils.mkdir_p(File.join("src", "out"))
21
18
  (1..5).each do |i|
22
- `touch src/test/test#{i}.java`
19
+ FileUtils.touch(File.join("src", "test#{i}.java"))
23
20
  end
24
21
  @project.dry_run
25
22
 
26
23
  (1..5).each do |i|
27
- `touch src/test/test#{i}.class`
24
+ FileUtils.touch(File.join("src", "test#{i}.class"))
28
25
  end
29
26
 
30
27
  (1..5).each do |i|
31
- `touch src/test/out/test#{i}.jar`
28
+ FileUtils.touch(File.join("src", "out", "test#{i}.jar"))
32
29
  end
33
30
 
34
31
  @project.finish(false)
@@ -36,11 +33,11 @@ describe Tetra::Package do
36
33
 
37
34
  FileUtils.copy(File.join("spec", "data", "nailgun", "pom.xml"), @project_path)
38
35
 
39
- @package = Tetra::Package.new(@project, "test", File.join(@project_path, "pom.xml"), "*.jar")
36
+ @package = Tetra::Package.new(@project, File.join(@project_path, "pom.xml"), "*.jar")
40
37
  end
41
38
 
42
39
  after(:each) do
43
- FileUtils.rm_rf(@project_path)
40
+ delete_mock_project
44
41
  end
45
42
 
46
43
  describe "#to_spec" do
@@ -48,8 +45,8 @@ describe Tetra::Package do
48
45
  @package.to_spec
49
46
 
50
47
  @project.from_directory do
51
- spec_lines = File.readlines(File.join("output", "test", "test.spec"))
52
- expect(spec_lines).to include("Name: test\n")
48
+ spec_lines = File.readlines(File.join("output", "test-project", "test-project.spec"))
49
+ expect(spec_lines).to include("Name: test-project\n")
53
50
  expect(spec_lines).to include("License: The Apache Software License, Version 2.0\n")
54
51
  expect(spec_lines).to include("Summary: Nailgun is a client, protocol, and server for running Java\n")
55
52
  expect(spec_lines).to include("Url: http://martiansoftware.com/nailgun\n")
@@ -65,13 +62,13 @@ da39a3ee5e6b4b0d3255bfef95601890afd80709\n")
65
62
  describe "#to_archive" do
66
63
  it "generates an archive" do
67
64
  @project.from_directory("src") do
68
- FileUtils.touch(File.join("test", "src_test"))
65
+ FileUtils.touch("src_test")
69
66
  end
70
67
  @project.finish(false)
71
68
 
72
69
  @package.to_archive
73
70
  @project.from_directory do
74
- expect(`tar -Jtf output/test/test.tar.xz`.split).to include("src_test")
71
+ expect(`tar -Jtf output/test-project/test-project.tar.xz`.split).to include("src_test")
75
72
  end
76
73
  end
77
74
  end
@@ -35,54 +35,6 @@ describe Tetra::Project do
35
35
  end
36
36
  end
37
37
 
38
- describe ".get_package_name" do
39
- it "raises an error with a directory outside a tetra project" do
40
- expect do
41
- @project.get_package_name("/")
42
- end.to raise_error(Tetra::NoPackageDirectoryError)
43
- end
44
-
45
- it "raises an error with a tetra project directory" do
46
- expect do
47
- @project.get_package_name(@project_path)
48
- end.to raise_error(Tetra::NoPackageDirectoryError)
49
- end
50
-
51
- it "raises an error with a tetra kit directory" do
52
- expect do
53
- @project.get_package_name(File.join(@project_path, "kit"))
54
- end.to raise_error(Tetra::NoPackageDirectoryError)
55
- end
56
-
57
- it "raises an error with a tetra src directory" do
58
- expect do
59
- @project.get_package_name(File.join(@project_path, "src"))
60
- end.to raise_error(Tetra::NoPackageDirectoryError)
61
- end
62
-
63
- it "raises an error with a nonexisting package directory" do
64
- expect do
65
- @project.get_package_name(File.join(@project_path, "src", "test_package"))
66
- end.to raise_error(Tetra::NoPackageDirectoryError)
67
- end
68
-
69
- it "returns the package on an existing package directory" do
70
- FileUtils.mkdir_p(File.join(@project_path, "src", "test_package"))
71
- expect(@project.get_package_name(File.join(@project_path, "src", "test_package"))).to eq "test_package"
72
- end
73
-
74
- it "returns the package on an existing package subdirectory" do
75
- FileUtils.mkdir_p(File.join(@project_path, "src", "test_package", "subdir1"))
76
- expect(@project.get_package_name(File.join(@project_path, "src", "test_package", "subdir1"))).to eq "test_package"
77
- end
78
-
79
- it "returns the package on an existing package subsubdirectory" do
80
- FileUtils.mkdir_p(File.join(@project_path, "src", "test_package", "subdir1", "subdir2"))
81
- expect(@project.get_package_name(File.join(@project_path, "src", "test_package", "subdir1", "subdir2")))
82
- .to eq "test_package"
83
- end
84
- end
85
-
86
38
  describe "full_path" do
87
39
  it "returns the project's full path" do
88
40
  expect(@project.full_path).to eq File.expand_path(@project_path)
@@ -114,7 +66,7 @@ describe Tetra::Project do
114
66
  describe "#take_snapshot" do
115
67
  it "commits the project contents to git for later use" do
116
68
  @project.from_directory do
117
- `touch kit/test`
69
+ FileUtils.touch(File.join("kit", "test"))
118
70
 
119
71
  @project.take_snapshot("test", :revertable)
120
72
 
@@ -127,8 +79,7 @@ describe Tetra::Project do
127
79
  describe "#finish" do
128
80
  it "ends the current dry-run phase after a successful build" do
129
81
  @project.from_directory do
130
- Dir.mkdir("src/abc")
131
- `echo A > src/abc/test`
82
+ File.open(File.join("src", "test"), "w") { |f| f.write("A") }
132
83
  end
133
84
 
134
85
  expect(@project.finish(true)).to be_falsey
@@ -137,8 +88,8 @@ describe Tetra::Project do
137
88
  expect(@project.dry_run).to be_truthy
138
89
 
139
90
  @project.from_directory do
140
- `echo B > src/abc/test`
141
- `touch src/abc/test2`
91
+ File.open(File.join("src", "test"), "w") { |f| f.write("B") }
92
+ FileUtils.touch(File.join("src", "test2"))
142
93
  end
143
94
 
144
95
  expect(@project.finish(false)).to be_truthy
@@ -146,17 +97,16 @@ describe Tetra::Project do
146
97
 
147
98
  @project.from_directory do
148
99
  expect(`git rev-list --all`.split("\n").length).to eq 4
149
- expect(File.read("src/abc/test")).to eq "A\n"
100
+ expect(File.read("src/test")).to eq "A"
150
101
 
151
- expect(`git diff-tree --no-commit-id --name-only -r HEAD~`.split("\n")).to include("src/abc/test2")
152
- expect(File.exist?("src/abc/test2")).to be_falsey
102
+ expect(`git diff-tree --no-commit-id --name-only -r HEAD~`.split("\n")).to include("src/test2")
103
+ expect(File.exist?("src/test2")).to be_falsey
153
104
  end
154
105
  end
155
106
  it "ends the current dry-run phase after a failed build" do
156
107
  @project.from_directory do
157
- Dir.mkdir("src/abc")
158
- `echo A > src/abc/test`
159
- `echo A > kit/test`
108
+ File.open(File.join("src", "test"), "w") { |f| f.write("A") }
109
+ File.open(File.join("kit", "test"), "w") { |f| f.write("A") }
160
110
  end
161
111
 
162
112
  expect(@project.finish(true)).to be_falsey
@@ -165,10 +115,10 @@ describe Tetra::Project do
165
115
  expect(@project.dry_run).to be_truthy
166
116
 
167
117
  @project.from_directory do
168
- `echo B > src/abc/test`
169
- `touch src/abc/test2`
170
- `echo B > kit/test`
171
- `touch kit/test2`
118
+ File.open(File.join("src", "test"), "w") { |f| f.write("B") }
119
+ FileUtils.touch(File.join("src", "test2"))
120
+ File.open(File.join("kit", "test"), "w") { |f| f.write("B") }
121
+ FileUtils.touch(File.join("kit", "test2"))
172
122
  end
173
123
 
174
124
  expect(@project.finish(true)).to be_truthy
@@ -176,10 +126,10 @@ describe Tetra::Project do
176
126
 
177
127
  @project.from_directory do
178
128
  expect(`git rev-list --all`.split("\n").length).to eq 2
179
- expect(File.read("src/abc/test")).to eq "A\n"
180
- expect(File.exist?("src/abc/test2")).to be_falsey
129
+ expect(File.read("src/test")).to eq "A"
130
+ expect(File.exist?("src/test2")).to be_falsey
181
131
 
182
- expect(File.read("kit/test")).to eq "A\n"
132
+ expect(File.read("kit/test")).to eq "A"
183
133
  expect(File.exist?("kit/test2")).to be_falsey
184
134
  end
185
135
  end
@@ -190,7 +140,7 @@ describe Tetra::Project do
190
140
  expect(@project.finish(false)).to be_falsey
191
141
 
192
142
  @project.from_directory do
193
- `touch src/test`
143
+ FileUtils.touch(File.join("src", "test"))
194
144
  end
195
145
 
196
146
  @project.from_directory("src") do
@@ -206,27 +156,26 @@ describe Tetra::Project do
206
156
  end
207
157
  end
208
158
 
209
- describe "#get_produced_files" do
159
+ describe "#produced_files" do
210
160
  it "gets a list of produced files" do
211
161
  @project.from_directory do
212
- Dir.mkdir("src/abc")
213
- `echo A > src/abc/added_outside_dry_run`
162
+ File.open(File.join("src", "added_outside_dry_run"), "w") { |f| f.write("A") }
214
163
  end
215
164
 
216
165
  expect(@project.dry_run).to be_truthy
217
166
  @project.from_directory do
218
- `echo A > src/abc/added_in_first_dry_run`
219
- `echo A > src/added_outside_directory`
167
+ File.open(File.join("src", "added_in_first_dry_run"), "w") { |f| f.write("A") }
168
+ File.open("added_outside_directory", "w") { |f| f.write("A") }
220
169
  end
221
170
  expect(@project.finish(false)).to be_truthy
222
171
 
223
172
  expect(@project.dry_run).to be_truthy
224
173
  @project.from_directory do
225
- `echo A > src/abc/added_in_second_dry_run`
174
+ File.open(File.join("src", "added_in_second_dry_run"), "w") { |f| f.write("A") }
226
175
  end
227
176
  expect(@project.finish(false)).to be_truthy
228
177
 
229
- list = @project.get_produced_files("abc")
178
+ list = @project.produced_files
230
179
  expect(list).to include("added_in_first_dry_run")
231
180
  expect(list).to include("added_in_second_dry_run")
232
181
 
@@ -238,7 +187,7 @@ describe Tetra::Project do
238
187
  describe "#purge_jars" do
239
188
  it "moves jars in kit/jars" do
240
189
  @project.from_directory do
241
- `echo "jarring" > src/test.jar`
190
+ File.open(File.join("src", "test.jar"), "w") { |f| f.write("jarring") }
242
191
  end
243
192
  expect(@project.finish(false)).to be_falsey
244
193
 
@@ -247,7 +196,7 @@ describe Tetra::Project do
247
196
  @project.from_directory do
248
197
  expect(File.symlink?(File.join("src", "test.jar"))).to be_truthy
249
198
  expect(File.readlink(File.join("src", "test.jar"))).to eq "../kit/jars/test.jar"
250
- expect(File.readlines(File.join("kit", "jars", "test.jar"))).to include("jarring\n")
199
+ expect(File.readlines(File.join("kit", "jars", "test.jar"))).to include("jarring")
251
200
  end
252
201
  end
253
202
  end
@@ -36,9 +36,9 @@ describe Tetra::ScriptGenerator do
36
36
  describe "#generate_build_script" do
37
37
  it "generates a build script from the history" do
38
38
  @project.from_directory do
39
- @generator.generate_build_script("test-package")
39
+ @generator.generate_build_script
40
40
 
41
- lines = File.readlines(File.join("src", "test-package", "build.sh"))
41
+ lines = File.readlines(File.join("src", "build.sh"))
42
42
 
43
43
  expect(lines).to include("#!/bin/bash\n")
44
44
  expect(lines).to include("cd somewhere significant\n")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tetra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.41.0
4
+ version: 0.42.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-13 00:00:00.000000000 Z
12
+ date: 2014-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -158,8 +158,10 @@ files:
158
158
  - Rakefile
159
159
  - SPECIAL_CASES.md
160
160
  - bin/tetra
161
+ - integration-tests/apache-maven-3.1.1-bin.zip
161
162
  - integration-tests/build-commons.sh
162
163
  - integration-tests/build-obs.sh
164
+ - integration-tests/commons-collections-3.2.1-src.zip
163
165
  - lib/template/gitignore
164
166
  - lib/template/kit/CONTENTS
165
167
  - lib/template/kit/jars/CONTENTS