Skip to content

Commit

Permalink
Check internal dependencies of maven artifacts (digital-asset#3454)
Browse files Browse the repository at this point in the history
* Check internal dependencies of maven artifacts

All artifacts that are uploaded to maven need to also have
their dependencies uploaded to maven.

* inline tuple matching

* remove unnecessary parenthesis

* mark missing artifacts for maven upload
  • Loading branch information
gerolf-da authored and hurryabit committed Nov 14, 2019
1 parent 4eb72d4 commit e760d47
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ledger/sandbox/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ da_scala_library(
"@maven//:ch_qos_logback_logback_classic",
"@maven//:ch_qos_logback_logback_core",
],
deps = compileDependencies + ["//ledger/test-common"],
deps = compileDependencies,
)

da_scala_library(
Expand All @@ -115,7 +115,7 @@ da_scala_library(
"@maven//:ch_qos_logback_logback_classic",
"@maven//:ch_qos_logback_logback_core",
],
deps = compileDependencies + ["//ledger/test-common"],
deps = compileDependencies,
)

da_scala_binary(
Expand Down
22 changes: 20 additions & 2 deletions release/artifacts.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- target: //daml-lf/data:data
type: jar-scala
mavenUpload: True
- target: //daml-lf/archive:daml_lf_dev_archive_java_proto
type: jar-lib
javadoc-jar: daml_lf_dev_archive_java_proto_javadoc.jar
Expand Down Expand Up @@ -40,6 +41,7 @@
artifactId: daml-lf-1.7-archive-proto
- target: //daml-lf/archive:daml_lf_archive_reader
type: jar-scala
mavenUpload: True
- target: //compiler/damlc/jar:damlc_jar
type: jar-deploy
platformDependent: True
Expand All @@ -51,22 +53,29 @@
type: jar-proto
- target: //daml-lf/transaction:transaction
type: jar-scala
mavenUpload: True
- target: //daml-lf/data-scalacheck:data-scalacheck
type: jar-scala
- target: //daml-lf/transaction-scalacheck:transaction-scalacheck
type: jar-scala
- target: //daml-lf/language:language
type: jar-scala
mavenUpload: True
- target: //daml-lf/interface:interface
type: jar-scala
mavenUpload: True
- target: //daml-lf/validation:validation
type: jar-scala
mavenUpload: True
- target: //daml-lf/interpreter:interpreter
type: jar-scala
mavenUpload: True
- target: //daml-lf/scenario-interpreter:scenario-interpreter
type: jar-scala
mavenUpload: True
- target: //daml-lf/engine:engine
type: jar-scala
mavenUpload: True
- target: //daml-lf/repl:repl
type: jar
- target: //ledger-api/grpc-definitions:ledger-api-protos-tarball
Expand Down Expand Up @@ -101,20 +110,28 @@
mavenUpload: True
- target: //ledger-api/rs-grpc-akka:rs-grpc-akka
type: jar-scala
mavenUpload: True
- target: //ledger/ledger-api-akka:ledger-api-akka
type: jar-scala
mavenUpload: True
- target: //scala-protoc-plugins/scala-logging:scala-logging-lib
type: jar-scala
mavenUpload: True
- target: //ledger/ledger-api-scala-logging:ledger-api-scala-logging
type: jar-scala
mavenUpload: True
- target: //ledger/ledger-api-client:ledger-api-client
type: jar-scala
mavenUpload: true
- target: //ledger/ledger-api-domain:ledger-api-domain
type: jar-scala
mavenUpload: True
- target: //ledger/ledger-api-common:ledger-api-common
type: jar-scala
mavenUpload: True
- target: //ledger/ledger-api-auth:ledger-api-auth
type: jar-scala
mavenUpload: True
- target: //ledger/ledger-api-grpc-utils:ledger-api-grpc-utils
type: jar-scala
mavenUpload: True
Expand All @@ -131,18 +148,18 @@
mavenUpload: True
- target: //language-support/java/codegen:shaded_binary
type: jar-scala
mavenUpload: True
- target: //navigator/backend:navigator-binary
type: jar-deploy
- target: //language-support/codegen-common:codegen-common
type: jar-scala
- target: //language-support/codegen-main:shaded_binary
type: jar-scala
mavenUpload: True
- target: //ledger/participant-state:participant-state
type: jar-scala
mavenUpload: True
- target: //ledger/participant-state-index:participant-state-index
type: jar-scala
mavenUpload: True
- target: //ledger/sandbox:ledger-api-server
type: jar-scala
mavenUpload: True
Expand All @@ -156,6 +173,7 @@
type: jar-scala
- target: //ledger-service/jwt:jwt
type: jar-scala
mavenUpload: True
- target: //ledger-service/db-backend:db-backend
type: jar-scala
- target: //ledger-service/http-json:http-json
Expand Down
26 changes: 25 additions & 1 deletion release/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import Control.Monad.Extra
import Control.Monad.IO.Class
import Control.Monad.Logger
import Data.Yaml
import qualified Data.Set as Set
import qualified Data.List as List
import Path
import Path.IO

import qualified Data.Text as T
import qualified Data.Maybe as Maybe
import qualified System.Directory as Dir
import System.Exit
import System.Process

import Options
Expand Down Expand Up @@ -47,12 +49,34 @@ main = do
$logInfo "Reading metadata from pom files"
artifacts <- liftIO $ mapM (resolvePomData bazelLocations sdkVersion compVersion) artifacts

let mavenUploadArtifacts = filter (\a -> getMavenUpload $ artMavenUpload a) artifacts

-- all known targets uploaded to maven
let allMavenTargets = Set.fromList $ fmap (T.unpack . getBazelTarget . artTarget) mavenUploadArtifacts

-- first find out all the missing internal dependencies
missingDepsForAllArtifacts <- forM mavenUploadArtifacts $ \a -> do
-- run a bazel query to find all internal java and scala library dependencies
let bazelQueryCommand = shell $ "bazel query 'kind(\"(scala|java)_library\", deps(" ++ (T.unpack . getBazelTarget . artTarget) a ++ ")) intersect //...'"
internalDeps <- liftIO $ lines <$> readCreateProcess bazelQueryCommand ""
-- check if a dependency is not already a maven target from artifacts.yaml
let missingDeps = filter (`Set.notMember` allMavenTargets) internalDeps
return (a, missingDeps)

let onlyMissing = filter (not . null . snd) missingDepsForAllArtifacts
-- now we can report all the missing dependencies per artifact
when (not (null onlyMissing)) $ do
$logError "Some internal dependencies are not published to maven central!"
forM_ onlyMissing $ \(artifact, missingDeps) -> do
$logError (getBazelTarget (artTarget artifact))
forM_ missingDeps $ \dep -> $logError ("\t- "# T.pack dep)
liftIO exitFailure

files <- fmap concat $ forM artifacts $ \a -> do
fs <- artifactFiles optsAllArtifacts a
pure $ map (a,) fs
mapM_ (\(_, (inp, outp)) -> copyToReleaseDir bazelLocations releaseDir inp outp) files

let mavenUploadArtifacts = filter (\a -> getMavenUpload $ artMavenUpload a) artifacts
uploadArtifacts <- concatMapM (mavenArtifactCoords optsAllArtifacts) mavenUploadArtifacts
validateMavenArtifacts releaseDir uploadArtifacts

Expand Down

0 comments on commit e760d47

Please sign in to comment.