Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Commit

Permalink
fix(maven): Locators should include group ID (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
elldritch authored Aug 16, 2021
1 parent be527bc commit d3fed67
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Spectrometer Changelog

## v2.15.2

- Maven: Fixes an issue where dependencies parsed from `dependency:tree` would fail to resolve when uploaded. ([#332](https://github.com/fossas/spectrometer/pull/332))

## v2.15.1

- Maven: Fixes an issue where dependencies with a platform specifier were not correctly parsed. ([#329](https://github.com/fossas/spectrometer/pull/329))
Expand Down
5 changes: 3 additions & 2 deletions src/Strategy/Maven/DepTree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Strategy.Maven.DepTree (
-- * Exported for testing
DotGraph (..),
PackageId (..),
toDependency,
) where

import Control.Algebra (Has, run)
Expand Down Expand Up @@ -144,10 +145,10 @@ buildGraph :: [DotGraph] -> Graphing Dependency
buildGraph = gmap toDependency . foldMap toGraph

toDependency :: PackageId -> Dependency
toDependency PackageId{artifactName, artifactVersion, buildTag} =
toDependency PackageId{groupName, artifactName, artifactVersion, buildTag} =
Dependency
{ dependencyType = MavenType
, dependencyName = artifactName
, dependencyName = groupName <> ":" <> artifactName
, dependencyVersion = Just $ CEq artifactVersion
, dependencyLocations = []
, dependencyEnvironments = maybe [EnvProduction] ((: []) . toBuildTag) buildTag
Expand Down
36 changes: 34 additions & 2 deletions test/Maven/DepTreeSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@ module Maven.DepTreeSpec (spec) where

import Data.Text (Text)
import Data.Text.IO qualified as TextIO
import Strategy.Maven.DepTree (DotGraph (..), PackageId (..), parseDotGraphs)
import Test.Hspec (Spec, describe, it, runIO)
import DepTypes (
DepEnvironment (..),
DepType (MavenType),
Dependency (..),
VerConstraint (..),
)
import Strategy.Maven.DepTree (
DotGraph (..),
PackageId (..),
parseDotGraphs,
toDependency,
)
import Test.Hspec (Spec, describe, it, runIO, shouldBe)
import Test.Hspec.Megaparsec (shouldParse, shouldSucceedOn)
import Text.Megaparsec (parse)

Expand All @@ -30,6 +41,27 @@ spec =
parse parseDotGraphs "" fixturePackageIDWithPlatformContents
`shouldParse` fixturePackageIDWithPlatformGraph

it "renders parsed dependencies" $ do
let p =
PackageId
{ groupName = "org.apache.commons"
, artifactName = "commons-rng-parent"
, artifactType = "pom"
, artifactVersion = "1.4-SNAPSHOT"
, artifactPlatform = Nothing
, buildTag = Nothing
}
let d =
Dependency
{ dependencyType = MavenType
, dependencyName = "org.apache.commons:commons-rng-parent"
, dependencyVersion = Just (CEq "1.4-SNAPSHOT")
, dependencyLocations = []
, dependencyEnvironments = [EnvProduction]
, dependencyTags = mempty
}
toDependency p `shouldBe` d

fixtureSingleFile :: FilePath
fixtureSingleFile = "test/Maven/testdata/fossa-deptree.dot"

Expand Down

0 comments on commit d3fed67

Please sign in to comment.