gjp 0.13.1 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -14,19 +14,26 @@ Easiest install is via RubyGems:
14
14
 
15
15
  ## Usage
16
16
 
17
- Currently available tools:
17
+ Main workflow subcommands:
18
18
  * `gjp init` inits a new gjp project in the current directory, generating minimal directories and files;
19
- * `gjp gather` starts a new gathering phase, to add files to the packages you want to create. You should place source files in src/<orgId_artifactId_version>, and binary dependency files in kit/;
19
+ * `gjp gather` starts a new gathering phase, to add files to the packages you want to create. You should place source files in src/<orgId:artifactId:version>, and binary dependency files in kit/;
20
+ * `gjp dry-run` starts a new dry-run phase, where you attempt to build your package. Any change to src/ will be reverted after you call `gjp finish`
21
+ * `gjp finish` ends the current phase;
22
+ * `gjp mvn` locates and runs Maven from any directory in kit/, using options to force repository in kit/m2 and settings in kit/m2/settings.xml. Use during dry runs;
23
+ superuser privileges;
24
+ * `gjp generate-kit-spec` creates or refreshes a spec file for the kit package. Use when you are finished gathering and dry-running;
25
+ * `gjp generate-kit-archive` creates or refreshes an archive file for the kit package. Use when you are finished gathering and dry-running;
26
+ * `gjp generate-source-archive NAME` creates or refreshes an archive file for source package NAME. Use when you are finished gathering and dry-running;
27
+
28
+ Optional workflow subcommands:
29
+ * `gjp set-up-nonet-user` sets up a user named `nonet` without Internet access you can use for networkless dry runs. Requires `iptables` and
30
+ * `gjp tear-down-nonet-user` removes a user previously created by gjp;
31
+
32
+ Other available tools:
20
33
  * `gjp get-pom NAME` will attempt to find a pom. `NAME` can be a jar file on your disk, a project directory, or simply a `name-version` string. `gjp` will get the pom either from the package itself or through search.maven.org using heuristic searching;
21
34
  * `gjp get-parent-pom POM` will attempt to download a pom's parent from search.maven.org, where `POM` is a filename or URI;
22
35
  * `gjp get-source-address POM` will attempt to find the SCM Internet address of a pom.xml from the file itself or through api.github.com. `POM` can either be a filename or a URI;
23
36
  * `gjp get-source POM ADDRESS` downloads the source of a pom.xml's project from its SCM at ADDRESS;
24
- * `gjp finish` marks the end of a phase;
25
- * `gjp dry-run` starts a new dry-run phase, where you attempt to build your package. Any change to src/ will be reverted after you call `gjp finish`;
26
- * `gjp mvn` locates and runs Maven from any directory in kit/, using options to force repository in kit/m2 and settings in kit/m2/settings.xml;
27
- * `gjp scaffold-kit-spec` creates or refreshes a spec file for the kit package;
28
- * `gjp set-up-nonet-user` sets up a user named `nonet` without Internet access using `iptables`, needs superuser privileges. You can then use it for networkless dry-runs;
29
- * `gjp tear-down-nonet-user` removes a user previously created by gjp;
30
37
  * `gjp scaffold-jar-table DIRECTORY` looks for jars in the project's DIRECTORY and classifies them as build-time dependencies (b), run-time dependencies (r) or products (p);
31
38
 
32
39
  ## Source
data/lib/gjp/archiver.rb CHANGED
@@ -14,7 +14,7 @@ module Gjp
14
14
  def archive_kit
15
15
  list_file = File.join(@project.full_path, "file_lists/kit")
16
16
  if not File.exist? list_file
17
- return false
17
+ return nil
18
18
  end
19
19
  destination_file = File.join(@project.full_path, "archives/#{@project.name}-kit.tar.xz")
20
20
 
@@ -22,7 +22,7 @@ module Gjp
22
22
  archive list_file, destination_file
23
23
  end
24
24
 
25
- true
25
+ Pathname.new(destination_file).relative_path_from Pathname.new(@project.full_path)
26
26
  end
27
27
 
28
28
  # generates an archive for a project's source package based on
@@ -30,7 +30,7 @@ module Gjp
30
30
  def archive_src(name)
31
31
  list_file = File.join(@project.full_path, "file_lists/#{name}_input")
32
32
  if not File.exist? list_file
33
- return false
33
+ return nil
34
34
  end
35
35
  destination_file = File.join(@project.full_path, "archives/#{@project.name}-#{name}.tar.xz")
36
36
 
@@ -38,7 +38,7 @@ module Gjp
38
38
  archive list_file, destination_file
39
39
  end
40
40
 
41
- true
41
+ Pathname.new(destination_file).relative_path_from Pathname.new(@project.full_path)
42
42
  end
43
43
 
44
44
  # compresses files specified in the list file to the destination file
data/lib/gjp/cli.rb CHANGED
@@ -109,22 +109,21 @@ module Gjp
109
109
  end
110
110
  end
111
111
 
112
- subcommand "scaffold-kit-spec", "Scaffolds or refreshes a spec file for the kit package" do
112
+ subcommand "generate-kit-spec", "Scaffolds or refreshes a spec file for the kit package" do
113
113
  def execute
114
114
  project = Gjp::Project.new(".")
115
- success = Gjp::Scaffolder.new(project).scaffold_kit_spec
116
- if not success
117
- puts "You must be gathering before scaffolding."
118
- puts "Use \"gjp gather\" to start a new gathering."
119
- end
115
+ result_path = Gjp::Scaffolder.new(project).scaffold_kit_spec
116
+ puts "#{result_path} generated"
120
117
  end
121
118
  end
122
119
 
123
120
  subcommand "generate-kit-archive", "Archives contents of the kit package in a tarball" do
124
121
  def execute
125
122
  project = Gjp::Project.new(".")
126
- success = Gjp::Archiver.new(project).archive_kit
127
- if not success
123
+ result_path = Gjp::Archiver.new(project).archive_kit
124
+ if result_path != nil
125
+ puts "#{result_path} generated"
126
+ else
128
127
  "The file_list/kit file was not found. Ensure you already added content to kit/ " +
129
128
  "during a gathering and/or dry-running phase, and ensure you ended that phase " +
130
129
  "with \"gjp finish\"."
@@ -136,8 +135,10 @@ module Gjp
136
135
  parameter "NAME", "name of a package in src/"
137
136
  def execute
138
137
  project = Gjp::Project.new(".")
139
- success = Gjp::Archiver.new(project).archive_src name
140
- if not success
138
+ result_path = Gjp::Archiver.new(project).archive_src name
139
+ if result_path != nil
140
+ puts "#{result_path} generated"
141
+ else
141
142
  "The file_list/#{name}_input file was not found. Ensure you already added content to " +
142
143
  "src/#{name} during a gathering phase, and ensure you ended that phase with \"gjp finish\"."
143
144
  end
data/lib/gjp/project.rb CHANGED
@@ -42,18 +42,18 @@ module Gjp
42
42
  `git init`
43
43
  end
44
44
 
45
+ Dir.mkdir "src"
46
+ Dir.mkdir "kit"
47
+
48
+ # automatically begin a gathering phase
49
+ Project.new(".").gather
50
+
45
51
  template_manager = Gjp::TemplateManager.new
46
52
  template_manager.copy "archives", "."
47
53
  template_manager.copy "file_lists", "."
48
54
  template_manager.copy "kit", "."
49
55
  template_manager.copy "specs", "."
50
56
  template_manager.copy "src", "."
51
-
52
- `git add .`
53
- `git commit -m "Project initialized"`
54
-
55
- # automatically begin a gathering phase
56
- Project.new(".").gather
57
57
  end
58
58
  end
59
59
 
@@ -187,7 +187,7 @@ module Gjp
187
187
 
188
188
  # returns the last tag given in a gjp snapshot
189
189
  def latest_tag(tag)
190
- `git describe --abbrev=0 --tags --match=gjp_#{tag}_*`.strip
190
+ `git describe --abbrev=0 --tags --match=gjp_#{tag}_* --always`.strip
191
191
  end
192
192
 
193
193
  # reverts path contents as per latest tag
@@ -10,10 +10,6 @@ module Gjp
10
10
  end
11
11
 
12
12
  def scaffold_kit_spec
13
- if @project.get_status != :gathering
14
- return false
15
- end
16
-
17
13
  @project.from_directory do
18
14
  spec_path = File.join("specs", "#{@project.name}-kit.spec")
19
15
 
@@ -35,7 +31,7 @@ module Gjp
35
31
 
36
32
  @project.take_snapshot "Kit spec scaffolded", :scaffold_kit_spec
37
33
 
38
- true
34
+ spec_path
39
35
  end
40
36
  end
41
37
  end
data/lib/gjp/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Gjp
4
- VERSION = "0.13.1"
4
+ VERSION = "0.14.1"
5
5
  end
@@ -19,11 +19,13 @@ Name: <%= name %>-kit
19
19
  Version: <%= version %>
20
20
  Release: 1
21
21
  License: Apache-2.0
22
- Summary: Build-time dependencies for %{name}
22
+ Summary: Build-time dependencies for gjp project <%= name %>
23
23
  Url: https://github.com/SilvioMoioli/gjp
24
- Group: Develompent/Libraries/Java
24
+ Group: Development/Libraries/Java
25
25
  Source0: %{name}.tar.xz
26
26
  BuildRoot: %{_tmppath}/%{name}-%{version}-build
27
+ BuildRequires: java-devel
28
+ BuildArch: noarch
27
29
  Provides: gjp(kit)
28
30
  # no two kits should ever be installed at any given time
29
31
  Conflicts: otherproviders(gjp(kit))
@@ -35,7 +37,7 @@ not be used except for rebuilding those packages and it should never
35
37
  be installed on end users' systems.
36
38
 
37
39
  %prep
38
- %setup -q
40
+ %setup -q -c
39
41
 
40
42
  %build
41
43
  # nothing to do, gjp kits are precompiled by design
@@ -46,6 +48,7 @@ cp -a * %{buildroot}%{_datadir}/gjp/%{name}/
46
48
 
47
49
  %files
48
50
  %defattr(-,root,root)
51
+ %{_datadir}/gjp
49
52
  %{_datadir}/gjp/%{name}/
50
53
 
51
54
  %changelog
@@ -1,257 +1,10 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
 
3
3
  <!--
4
- Licensed to the Apache Software Foundation (ASF) under one
5
- or more contributor license agreements. See the NOTICE file
6
- distributed with this work for additional information
7
- regarding copyright ownership. The ASF licenses this file
8
- to you under the Apache License, Version 2.0 (the
9
- "License"); you may not use this file except in compliance
10
- with the License. You may obtain a copy of the License at
11
-
12
- http://www.apache.org/licenses/LICENSE-2.0
13
-
14
- Unless required by applicable law or agreed to in writing,
15
- software distributed under the License is distributed on an
16
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
- KIND, either express or implied. See the License for the
18
- specific language governing permissions and limitations
19
- under the License.
20
- -->
21
-
22
- <!--
23
- | This is the configuration file for Maven. It can be specified at two levels:
24
- |
25
- | 1. User Level. This settings.xml file provides configuration for a single user,
26
- | and is normally provided in ${user.home}/.m2/settings.xml.
27
- |
28
- | NOTE: This location can be overridden with the CLI option:
29
- |
30
- | -s /path/to/user/settings.xml
31
- |
32
- | 2. Global Level. This settings.xml file provides configuration for all Maven
33
- | users on a machine (assuming they're all using the same Maven
34
- | installation). It's normally provided in
35
- | ${maven.home}/conf/settings.xml.
36
- |
37
- | NOTE: This location can be overridden with the CLI option:
38
- |
39
- | -gs /path/to/global/settings.xml
40
- |
41
- | The sections in this sample file are intended to give you a running start at
42
- | getting the most out of your Maven installation. Where appropriate, the default
43
- | values (values used when the setting is not specified) are provided.
44
- |
4
+ | This is the configuration file used by default by `gjp mvn`.
5
+ | Feel free to add settings here if any are needed for gjp dry runs.
45
6
  |-->
46
7
  <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
47
8
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
48
9
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
49
- <!-- localRepository
50
- | The path to the local repository maven will use to store artifacts.
51
- |
52
- | Default: ~/.m2/repository
53
- <localRepository>/path/to/local/repo</localRepository>
54
- -->
55
-
56
- <!-- interactiveMode
57
- | This will determine whether maven prompts you when it needs input. If set to false,
58
- | maven will use a sensible default value, perhaps based on some other setting, for
59
- | the parameter in question.
60
- |
61
- | Default: true
62
- <interactiveMode>true</interactiveMode>
63
- -->
64
-
65
- <!-- offline
66
- | Determines whether maven should attempt to connect to the network when executing a build.
67
- | This will have an effect on artifact downloads, artifact deployment, and others.
68
- |
69
- | Default: false
70
- <offline>false</offline>
71
- -->
72
-
73
- <!-- pluginGroups
74
- | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
75
- | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
76
- | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
77
- |-->
78
- <pluginGroups>
79
- <!-- pluginGroup
80
- | Specifies a further group identifier to use for plugin lookup.
81
- <pluginGroup>com.your.plugins</pluginGroup>
82
- -->
83
- </pluginGroups>
84
-
85
- <!-- proxies
86
- | This is a list of proxies which can be used on this machine to connect to the network.
87
- | Unless otherwise specified (by system property or command-line switch), the first proxy
88
- | specification in this list marked as active will be used.
89
- |-->
90
- <proxies>
91
- <!-- proxy
92
- | Specification for one proxy, to be used in connecting to the network.
93
- |
94
- <proxy>
95
- <id>optional</id>
96
- <active>true</active>
97
- <protocol>http</protocol>
98
- <username>proxyuser</username>
99
- <password>proxypass</password>
100
- <host>proxy.host.net</host>
101
- <port>80</port>
102
- <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
103
- </proxy>
104
- -->
105
- </proxies>
106
-
107
- <!-- servers
108
- | This is a list of authentication profiles, keyed by the server-id used within the system.
109
- | Authentication profiles can be used whenever maven must make a connection to a remote server.
110
- |-->
111
- <servers>
112
- <!-- server
113
- | Specifies the authentication information to use when connecting to a particular server, identified by
114
- | a unique name within the system (referred to by the 'id' attribute below).
115
- |
116
- | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
117
- | used together.
118
- |
119
- <server>
120
- <id>deploymentRepo</id>
121
- <username>repouser</username>
122
- <password>repopwd</password>
123
- </server>
124
- -->
125
-
126
- <!-- Another sample, using keys to authenticate.
127
- <server>
128
- <id>siteServer</id>
129
- <privateKey>/path/to/private/key</privateKey>
130
- <passphrase>optional; leave empty if not used.</passphrase>
131
- </server>
132
- -->
133
- </servers>
134
-
135
- <!-- mirrors
136
- | This is a list of mirrors to be used in downloading artifacts from remote repositories.
137
- |
138
- | It works like this: a POM may declare a repository to use in resolving certain artifacts.
139
- | However, this repository may have problems with heavy traffic at times, so people have mirrored
140
- | it to several places.
141
- |
142
- | That repository definition will have a unique id, so we can create a mirror reference for that
143
- | repository, to be used as an alternate download site. The mirror site will be the preferred
144
- | server for that repository.
145
- |-->
146
- <mirrors>
147
- <!-- mirror
148
- | Specifies a repository mirror site to use instead of a given repository. The repository that
149
- | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
150
- | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
151
- |
152
- <mirror>
153
- <id>mirrorId</id>
154
- <mirrorOf>repositoryId</mirrorOf>
155
- <name>Human Readable Name for this Mirror.</name>
156
- <url>http://my.repository.com/repo/path</url>
157
- </mirror>
158
- -->
159
- </mirrors>
160
-
161
- <!-- profiles
162
- | This is a list of profiles which can be activated in a variety of ways, and which can modify
163
- | the build process. Profiles provided in the settings.xml are intended to provide local machine-
164
- | specific paths and repository locations which allow the build to work in the local environment.
165
- |
166
- | For example, if you have an integration testing plugin - like cactus - that needs to know where
167
- | your Tomcat instance is installed, you can provide a variable here such that the variable is
168
- | dereferenced during the build process to configure the cactus plugin.
169
- |
170
- | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
171
- | section of this document (settings.xml) - will be discussed later. Another way essentially
172
- | relies on the detection of a system property, either matching a particular value for the property,
173
- | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
174
- | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
175
- | Finally, the list of active profiles can be specified directly from the command line.
176
- |
177
- | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
178
- | repositories, plugin repositories, and free-form properties to be used as configuration
179
- | variables for plugins in the POM.
180
- |
181
- |-->
182
- <profiles>
183
- <!-- profile
184
- | Specifies a set of introductions to the build process, to be activated using one or more of the
185
- | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
186
- | or the command line, profiles have to have an ID that is unique.
187
- |
188
- | An encouraged best practice for profile identification is to use a consistent naming convention
189
- | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
190
- | This will make it more intuitive to understand what the set of introduced profiles is attempting
191
- | to accomplish, particularly when you only have a list of profile id's for debug.
192
- |
193
- | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
194
- <profile>
195
- <id>jdk-1.4</id>
196
-
197
- <activation>
198
- <jdk>1.4</jdk>
199
- </activation>
200
-
201
- <repositories>
202
- <repository>
203
- <id>jdk14</id>
204
- <name>Repository for JDK 1.4 builds</name>
205
- <url>http://www.myhost.com/maven/jdk14</url>
206
- <layout>default</layout>
207
- <snapshotPolicy>always</snapshotPolicy>
208
- </repository>
209
- </repositories>
210
- </profile>
211
- -->
212
-
213
- <!--
214
- | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
215
- | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
216
- | might hypothetically look like:
217
- |
218
- | ...
219
- | <plugin>
220
- | <groupId>org.myco.myplugins</groupId>
221
- | <artifactId>myplugin</artifactId>
222
- |
223
- | <configuration>
224
- | <tomcatLocation>${tomcatPath}</tomcatLocation>
225
- | </configuration>
226
- | </plugin>
227
- | ...
228
- |
229
- | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
230
- | anything, you could just leave off the <value/> inside the activation-property.
231
- |
232
- <profile>
233
- <id>env-dev</id>
234
-
235
- <activation>
236
- <property>
237
- <name>target-env</name>
238
- <value>dev</value>
239
- </property>
240
- </activation>
241
-
242
- <properties>
243
- <tomcatPath>/path/to/tomcat/instance</tomcatPath>
244
- </properties>
245
- </profile>
246
- -->
247
- </profiles>
248
-
249
- <!-- activeProfiles
250
- | List of profiles that are active for all builds.
251
- |
252
- <activeProfiles>
253
- <activeProfile>alwaysActiveProfile</activeProfile>
254
- <activeProfile>anotherAlwaysActiveProfile</activeProfile>
255
- </activeProfiles>
256
- -->
257
10
  </settings>
@@ -51,7 +51,7 @@ describe Gjp::Project do
51
51
 
52
52
  @project.from_directory do
53
53
  @project.latest_tag(:gathering_started).should eq "gjp_gathering_started_1"
54
- `git rev-list --all`.split("\n").length.should eq 2
54
+ `git rev-list --all`.split("\n").length.should eq 1
55
55
  end
56
56
 
57
57
  @project.get_status.should eq :gathering
@@ -84,7 +84,7 @@ describe Gjp::Project do
84
84
 
85
85
  @project.take_snapshot "test", :revertable
86
86
 
87
- `git rev-list --all`.split("\n").length.should eq 3
87
+ `git rev-list --all`.split("\n").length.should eq 2
88
88
  @project.latest_tag(:revertable).should eq "gjp_revertable_1"
89
89
  end
90
90
  end
@@ -120,7 +120,7 @@ describe Gjp::Project do
120
120
  @project.get_status.should be_nil
121
121
 
122
122
  @project.from_directory do
123
- `git rev-list --all`.split("\n").length.should eq 5
123
+ `git rev-list --all`.split("\n").length.should eq 4
124
124
  `git diff-tree --no-commit-id --name-only -r HEAD~2`.split("\n").should include("src/a:b:c/test")
125
125
  File.readlines(File.join("file_lists", "a:b:c_input")).should include("test\n")
126
126
  File.readlines(File.join("file_lists","kit")).should include("test\n")
@@ -147,7 +147,7 @@ describe Gjp::Project do
147
147
  @project.get_status.should be_nil
148
148
 
149
149
  @project.from_directory do
150
- `git rev-list --all`.split("\n").length.should eq 10
150
+ `git rev-list --all`.split("\n").length.should eq 9
151
151
  File.read("src/a:b:c/test").should eq "A\n"
152
152
  File.readlines(File.join("file_lists", "a:b:c_output")).should include("test2\n")
153
153
  File.readlines(File.join("file_lists", "a:b:c_input")).should_not include("test2\n")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gjp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.14.1
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: 2013-08-30 00:00:00.000000000 Z
12
+ date: 2013-09-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake