Skip to content

Commit cdb34da

Browse files
committed
Merge branch 'release/0.4.4'
2 parents cfb04ff + 0d2932b commit cdb34da

File tree

5 files changed

+79
-11
lines changed

5 files changed

+79
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Changelog of _Gradle Golang Plugin_
22

3-
## 0.5.0 (next version)
3+
## 0.4.4
44

5-
* The `fmt` task added to the life-cycle ([#])
6-
* The `vet` task added to the life-cycle ([#])
7-
* Code refactoring ([#])
5+
* Fix lifecycle error with optional proprietary vendors.
6+
([#15](https://github.com/sw-samuraj/gradle-godep-plugin/pull/15))
7+
* Document _How to handle proprietary vendors_.
8+
([#13](https://github.com/sw-samuraj/gradle-godep-plugin/pull/13),
9+
[#14](https://github.com/sw-samuraj/gradle-godep-plugin/pull/14))
810

911
## 0.4.3
1012

README.md

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ _Golang_ programs and manage their dependencies via _dep_ tool. The project
88
directory doesn't have to be in the standard `$GOAPTH` repository, therefore
99
you can locate your project repository anywhere on filesystem.
1010

11+
The plugin can deal with _"proprietary vendors"_ - package imports which are not in public repositories
12+
like [GitHub](https://github.com), or [Bitbucket](https://bitbucket.org), but are proprietary, e.g. repositories
13+
behind a company firewall etc. (see [Limitations](https://github.com/sw-samuraj/gradle-godep-plugin#limitations))
14+
1115
Plugin expects that _go_ and _dep_ commands are already installed on given system and that they are available on `$PATH`.
1216

1317
**Currently, only Unix systems are supported. Windows support can be added on demand.**
@@ -16,6 +20,7 @@ Plugin expects that _go_ and _dep_ commands are already installed on given syste
1620

1721
1. [Applying the plugin](https://github.com/sw-samuraj/gradle-godep-plugin#applying-the-plugin)
1822
1. [Using the plugin](https://github.com/sw-samuraj/gradle-godep-plugin#using-the-plugin)
23+
1. [How to handle proprietary vendors](https://github.com/sw-samuraj/gradle-godep-plugin#how-to-handle-proprietary-vendors)
1924
1. [Example](https://github.com/sw-samuraj/gradle-godep-plugin#example)
2025
1. [License](https://github.com/sw-samuraj/gradle-godep-plugin#license)
2126

@@ -25,7 +30,7 @@ Plugin expects that _go_ and _dep_ commands are already installed on given syste
2530

2631
```groovy
2732
plugins {
28-
id "cz.swsamuraj.godep" version "0.4.3"
33+
id "cz.swsamuraj.godep" version "0.4.4"
2934
}
3035
```
3136
### All Gradle versions (or local repository)
@@ -38,7 +43,7 @@ buildscript {
3843
}
3944
}
4045
dependencies {
41-
classpath "gradle.plugin.cz.swsamuraj:gradle-godep-plugin:0.4.3"
46+
classpath "gradle.plugin.cz.swsamuraj:gradle-godep-plugin:0.4.4"
4247
}
4348
}
4449
@@ -141,7 +146,64 @@ godep {
141146

142147
## How to handle proprietary vendors
143148

144-
TBD
149+
Go tools currently don't support package imports which are not in public repositories,
150+
such as [GitHub](https://github.com), [Bitbucket](https://bitbucket.org) etc. Therefore if you have a proprietary
151+
repository, e.g. behind a company firewall, you are on your own to solve all the dependency and build problems.
152+
The `gradle-godep-plugin` took a specific approach, how to handle this situation:
153+
154+
1. Use `dep` tool for solving of public imports, which are stored in the `vendor` directory.
155+
1. Clone proprietary imports via Gradle `proprietaryVendors` task to the `vendor` directory.
156+
157+
### Configuration
158+
159+
Unfortunately, configuration of the proprietary package imports has to be done on two places:
160+
161+
* **`build.gradle`** defines a map of package imports and their versions. These packages are clonned
162+
during execution of the `proprietaryVendors` task.
163+
* **`Gopkg.toml`** defines the same package imports (without versions) as `ignored`, so they can be ignored
164+
during execution of the `dep` task.
165+
* Eventually, if the proprietary package imports contain transitive dependencies on packages in public
166+
repositories, those have to be defined in the `Gopkg.toml` file as `required`.
167+
168+
Let's consider following example: we have a proprietary package `my.company.repo/cool-project/shared-package`
169+
which has a transitive dependency on the `github.com/coreos/etcd/clientv3` package.
170+
171+
**`build.gradle`:**
172+
173+
```groovy
174+
godep {
175+
// Map of import packages from non-public repositories.
176+
// The item in the map has an import path as a key and a tag
177+
// (or a branch) as a value.
178+
proprietaryVendors = [
179+
'my.company.repo/cool-project/shared-package': 'v0.1.0'
180+
]
181+
}
182+
```
183+
**`Gopkg.toml`:**
184+
185+
```toml
186+
# Needs to be filled only in case of transitive dependencies, otherwise can be omitted.
187+
required = [
188+
"github.com/coreos/etcd/clientv3"
189+
]
190+
191+
# It's the same package as in godep.proprietaryVendors map, only without version.
192+
ignored = [
193+
"my.company.repo/cool-project/shared-package"
194+
]
195+
196+
```
197+
198+
### Limitations
199+
200+
Currently, cloning of the proprietary vendors have these limitations:
201+
202+
* Cloning is done via _https_ only (e.g. `git clone https://xxx`).
203+
* Cloned repository has to be anonymously accessible.
204+
205+
_SSL_, or _https_ authentication could be added later, based on demand
206+
(please, fill an [issue](https://github.com/sw-samuraj/gradle-godep-plugin/issues)).
145207

146208
## Example
147209

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies {
1212
compile localGroovy()
1313
}
1414

15-
version = '0.4.3'
15+
version = '0.4.4'
1616
group = 'cz.swsamuraj'
1717

1818
jar {

example/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'cz.swsamuraj.godep' version '0.4.3'
2+
id 'cz.swsamuraj.godep' version '0.4.4'
33
}
44
/*
55
buildscript {
@@ -9,7 +9,7 @@ buildscript {
99
}
1010
}
1111
dependencies {
12-
classpath 'gradle.plugin.cz.swsamuraj:gradle-godep-plugin:0.5.0-SNAPSTHOT'
12+
classpath 'gradle.plugin.cz.swsamuraj:gradle-godep-plugin:0.5.0-SNAPSHOT'
1313
}
1414
}
1515

src/main/groovy/cz/swsamuraj/gradle/godep/GoDepPlugin.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ class GoDepPlugin implements Plugin<Project> {
7373
void afterEvaluate(Project proj, ProjectState projectState) {
7474
if (proj.tasks.findByPath('dep') != null) {
7575
if (extension.depOptional.get()) {
76-
proj.tasks.getByName('proprietaryVendors').setDependsOn(taskList(prepareWorkspaceTask))
76+
if (extension.proprietaryVendorsOptional.get()) {
77+
proj.tasks.getByName('test').setDependsOn(taskList(prepareWorkspaceTask))
78+
} else {
79+
proj.tasks.getByName('proprietaryVendors').setDependsOn(taskList(prepareWorkspaceTask))
80+
}
7781
}
7882
}
7983
if (proj.tasks.findByPath('proprietaryVendors') != null) {

0 commit comments

Comments
 (0)