From 126ac64bbf2056408a00afb98f78a76392ded1f4 Mon Sep 17 00:00:00 2001 From: Gary Verhaegen Date: Tue, 27 Aug 2019 18:08:52 +0200 Subject: [PATCH] daml-sdk-head also installs HEAD jars (#2652) --- dev-env/bin/daml-sdk-head | 26 ++++++++++++++++++++++++++ release/src/Main.hs | 20 +++++++++++++++----- release/src/Options.hs | 2 ++ unreleased.rst | 1 + 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/dev-env/bin/daml-sdk-head b/dev-env/bin/daml-sdk-head index 6eb06cb6b2..f925d49467 100755 --- a/dev-env/bin/daml-sdk-head +++ b/dev-env/bin/daml-sdk-head @@ -19,6 +19,7 @@ fi NUKE=0 PROFILING=0 +SKIP_JARS=0 for opt in "$@" ; do case $opt in "--nuke") @@ -27,6 +28,9 @@ for opt in "$@" ; do "--profiling") PROFILING=1 ;; + "--skip-jars") + SKIP_JARS=1; + ;; *) echo "Unknown option: $opt" echo "Available options:" @@ -95,3 +99,25 @@ chmod +x $DAML_HOME/bin/daml-head trap - EXIT echo "$(tput setaf 3)Successfully installed daml-head command.$(tput sgr 0)" +if [ "$SKIP_JARS" -eq "0" ]; then + echo "$(tput setaf 3)Installing JARs as 100.0.0...$(tput sgr 0)" + + cp "$REPO_ROOT/VERSION" "$REPO_ROOT/VERSION.head-build-in-progress" + + function cleanup() { + echo "$(tput setaf 3)FAILED TO INSTALL JARS! $(tput sgr 0)" + mv "$REPO_ROOT/VERSION.head-build-in-progress" "$REPO_ROOT/VERSION" + } + trap cleanup EXIT + + echo "0.0.0" > "$REPO_ROOT/VERSION" + + bazel build //release:release + tmp=$(mktemp -d) + "$REPO_ROOT/bazel-bin/release/release" --artifacts "$REPO_ROOT/release/artifacts.yaml" --release-dir $tmp --all-artifacts --install-head-jars + + mv "$REPO_ROOT/VERSION.head-build-in-progress" "$REPO_ROOT/VERSION" + trap - EXIT + + echo "$(tput setaf 3)Done installing JARs as 100.0.0.$(tput sgr 0)" +fi diff --git a/release/src/Main.hs b/release/src/Main.hs index bc4f8db8ea..26c39f2574 100644 --- a/release/src/Main.hs +++ b/release/src/Main.hs @@ -1,17 +1,19 @@ -- Copyright (c) 2019 The DAML Authors. All rights reserved. -- SPDX-License-Identifier: Apache-2.0 -{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TemplateHaskell, MultiWayIf #-} module Main (main) where import Control.Monad.Extra import Control.Monad.IO.Class import Control.Monad.Logger import Data.Yaml +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.Process @@ -54,8 +56,7 @@ main = do uploadArtifacts <- concatMapM (mavenArtifactCoords optsAllArtifacts) mavenUploadArtifacts validateMavenArtifacts releaseDir uploadArtifacts - if getPerformUpload upload - then do + if | getPerformUpload upload -> do $logInfo "Make release" releaseToBintray upload releaseDir (map (\(a, (_, outp)) -> (a, outp)) files) @@ -70,8 +71,17 @@ main = do -- set variables for next steps in Azure pipelines liftIO . putStrLn $ "##vso[task.setvariable variable=has_released;isOutput=true]true" liftIO . putStrLn . T.unpack $ "##vso[task.setvariable variable=release_tag]" # renderVersion sdkVersion - else $logInfo "Make dry run of release" - + | optsLocallyInstallJars -> do + let lib_jars = filter (\(mvn,_) -> (artifactType mvn == "jar" || artifactType mvn == "pom") && Maybe.isNothing (classifier mvn)) uploadArtifacts + forM_ lib_jars $ \(mvn_coords, path) -> do + let args = ["install:install-file", + "-Dfile=" <> pathToString releaseDir <> pathToString path, + "-DgroupId=" <> foldr (<>) "" (List.intersperse "." $ map T.unpack $ groupId mvn_coords), + "-DartifactId=" <> (T.unpack $ artifactId mvn_coords), + "-Dversion=100.0.0", + "-Dpackaging=" <> (T.unpack $ artifactType mvn_coords)] + liftIO $ callProcess "mvn" args + | otherwise -> $logInfo "Make dry run of release" where runLog Options{..} m0 = do let m = filterLogger (\_ ll -> ll >= optsLogLevel) m0 diff --git a/release/src/Options.hs b/release/src/Options.hs index 0500d687a8..fcc2401e6e 100644 --- a/release/src/Options.hs +++ b/release/src/Options.hs @@ -25,6 +25,7 @@ data Options = Options , optsFullLogging :: Bool , optsLogLevel :: LogLevel , optsAllArtifacts :: AllArtifacts + , optsLocallyInstallJars :: Bool } deriving (Eq, Show) optsParser :: Parser Options @@ -36,6 +37,7 @@ optsParser = Options <*> switch (long "full-logging" <> help "full logging detail") <*> option readLogLevel (long "log-level" <> metavar "debug|info|warn|error (default: info)" <> help "Specify log level during release run" <> value LevelInfo ) <*> (AllArtifacts <$> switch (long "all-artifacts" <> help "Produce all artifacts including platform-independent artifacts on MacOS")) + <*> switch (long "install-head-jars" <> help "install jars to ~/.m2") where readLogLevel :: ReadM LogLevel readLogLevel = do diff --git a/unreleased.rst b/unreleased.rst index ca491b82d6..aa4565002b 100644 --- a/unreleased.rst +++ b/unreleased.rst @@ -11,3 +11,4 @@ HEAD — ongoing + [Sandbox] The sandbox now properly sets the connection pool properties ``minimumIdle``, ``maximumPoolSize``, and ``connectionTimeout``. + [Java codegen] Fix bug caused the generation of duplicate methods that affected sources with data constructors with type parameters that are either non-unique or not presented in the same order as in the corresponding data type declaration. See `#2367 `__. +* [Dev Tooling] `daml-sdk-head` now installs current-workdir versions of all the published JARs (as version `100.0.0`) to the local Maven repo (`~/.m2`), to allow local testing of unreleased versions of the SDK against JVM-based applications. (Disable with `--skip-jars`)