Skip to content

Commit

Permalink
Merge pull request #82 from fossas/fix/fix-builders-config
Browse files Browse the repository at this point in the history
Fix/fix builders config
  • Loading branch information
xizhao committed Mar 3, 2018
2 parents db9710b + a5202e0 commit 7f4d52f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion builders/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func runInDir(dir string, name string, arg ...string) (string, string, error) {
// Utilities for debug logging
func runLogged(logger *logging.Logger, dir string, name string, arg ...string) (string, string, error) {
cmd := strings.Join(append([]string{name}, arg...), " ")
logger.Debugf("Running `%s`...", cmd)
logger.Debugf("Running `%s` in dir `%s`...", cmd, dir)
stdout, stderr, err := runInDir(dir, name, arg...)
if err != nil {
logger.Debugf("Running `%s` failed: %#v %#v", cmd, err, stderr)
Expand Down
4 changes: 2 additions & 2 deletions builders/gradle.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (builder *GradleBuilder) DiscoverModules(dir string) ([]config.ModuleConfig
gradleTask := strings.Split(trimmed, " - ")[0]
gradleLogger.Debugf("found gradle dependencies task: %s", gradleTask)
moduleConfigurations = append(moduleConfigurations, config.ModuleConfig{
Name: strings.Split(gradleTask, ":")[0], // Name is the gradle task name
Name: strings.Split(gradleTask, ":")[0] + ":compile", // Name is the gradle `task:configuration` (default to compile)
Path: "build.gradle",
Type: "gradle",
})
Expand All @@ -144,7 +144,7 @@ func (builder *GradleBuilder) DiscoverModules(dir string) ([]config.ModuleConfig
// Fall back to "app" as default task, even though technically it would be "" (root)
return []config.ModuleConfig{
config.ModuleConfig{
Name: "app",
Name: "app:compile",
Path: "build.gradle",
Type: "gradle",
},
Expand Down
3 changes: 2 additions & 1 deletion builders/maven.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (builder *MavenBuilder) DiscoverModules(dir string) ([]config.ModuleConfig,
}
moduleConfigs := make([]config.ModuleConfig, len(pomFilePaths))
for i, path := range pomFilePaths {
artifactName := filepath.Dir(path)
artifactName := filepath.Base(filepath.Dir(dir))
var artifactPom POMFile
if err := parseLoggedWithUnmarshaller(mavenLogger, path, &artifactPom, xml.Unmarshal); err == nil {
if artifactPom.Name != "" {
Expand All @@ -193,6 +193,7 @@ func (builder *MavenBuilder) DiscoverModules(dir string) ([]config.ModuleConfig,
artifactName = artifactPom.ArtifactID
}
}
path, _ := filepath.Rel(dir, path)
moduleConfigs[i] = config.ModuleConfig{
Name: artifactName,
Path: path,
Expand Down
2 changes: 1 addition & 1 deletion builders/ruby.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (builder *RubyBuilder) IsBuilt(m module.Module, allowUnresolved bool) (bool

output, _, err := runLogged(rubyLogger, m.Dir, builder.BundlerCmd, "check")
if err != nil {
if strings.Index(output, "Please run `bundle install`") != -1 {
if strings.Index(output, "`bundle install`") != -1 {
return false, nil
}
return false, err
Expand Down
2 changes: 1 addition & 1 deletion cmd/fossa/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func makeAPIRequest(method, endpoint, apiKey string, payload []byte) ([]byte, er
defer resp.Body.Close()

if resp.StatusCode == http.StatusForbidden {
return nil, fmt.Errorf("invalid API key %#v (try setting $FOSSA_API_KEY)", apiKey)
return nil, fmt.Errorf("invalid API key %#v (try setting $FOSSA_API_KEY); get one at https://fossa.io", apiKey)
} else if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("bad server response: %d", resp.StatusCode)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/fossa/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func doUpload(conf config.CLIConfig, results []normalizedModule) (string, error)
responseStr := string(responseBytes)

if resp.StatusCode == http.StatusForbidden {
return "", fmt.Errorf("invalid API key (check the $FOSSA_API_KEY environment variable)")
return "", fmt.Errorf("invalid API key (check the $FOSSA_API_KEY environment variable); get one at https://fossa.io")
} else if resp.StatusCode == http.StatusPreconditionRequired {
// TODO: handle "Managed Project" workflow
return "", fmt.Errorf("invalid project or revision; make sure this version is published and FOSSA has access to your repo. To submit a custom project, set Fetcher to `custom` in `.fossa.yml`")
Expand Down

0 comments on commit 7f4d52f

Please sign in to comment.