How to use the value of another key in a sbt task?

Freewind

Say I have defined such a sbt task:

name := "hello"

version := "1.0"

scalaVersion := "2.11.0"

val mykey = settingKey[Int]("demo key")

mykey := 100

val hello = taskKey[Unit]("demo task")

hello := {println("Hello, world" + mykey)}

I have defined a mykey whose value is 100, and I want to use it in another custom task hello, but when I run:

$ sbt
> hello

It outputs:

Hello, worldsbt.SettingKey$$anon$4@66db9b08

How can I get the value 100 of mykey?

Andrzej Jozwik

Use the value macro of the Key:

hello := { println("Hello, world " + mykey.value) }

mykey is of type SettingKey[String] and value - is a macro defined in sbt.std.MacroValue

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How to use the Computed Value to calculate another

분류에서Dev

how to use single variable to pass selected imageview value to another activity?

분류에서Dev

How to use value from one Style in another Style?

분류에서Dev

Use the value of a key as a key in mongodb aggregation

분류에서Dev

make one array the key and another array the value

분류에서Dev

How do I create an array using the order and value from one and the key of another?

분류에서Dev

Gulp - Get return value of one task from another

분류에서Dev

Dynamically getting One list value with the key of another list value

분류에서Dev

How to iterate through a list and while iterating, iterate through another list and replace values for upper list with inner list key value pairs

분류에서Dev

How to make another key instead of replacing it in firebase

분류에서Dev

Using value of members in a list as the key to another list in Tcl

분류에서Dev

sbt`Task` 태그 나열

분류에서Dev

How to add a key,value pair to a list?

분류에서Dev

How can a key be part of value in a hash?

분류에서Dev

How to increment with the new value when on duplicate key?

분류에서Dev

How to remove dictionary key with known value?

분류에서Dev

How to parse an JSON Empty Key Value in iOS?

분류에서Dev

How to configure ssh to use different key?

분류에서Dev

How to execute war task only if a property equals to a particular value

분류에서Dev

How to use Format files in SSIS Data Flow task?

분류에서Dev

how to call a variable value in another php file

분류에서Dev

How to pass the 'self' value of a method to another method?

분류에서Dev

How to pass the autocompleted value into another function?

분류에서Dev

How to get the value for one function to another?

분류에서Dev

how to use the output value in php

분류에서Dev

How to use one function in another with classes in Python

분류에서Dev

How to use my project on another computer

분류에서Dev

How can I use another drive with Owncloud?

분류에서Dev

CSS: Use number of a class/id as value for another class/id

Related 관련 기사

  1. 1

    How to use the Computed Value to calculate another

  2. 2

    how to use single variable to pass selected imageview value to another activity?

  3. 3

    How to use value from one Style in another Style?

  4. 4

    Use the value of a key as a key in mongodb aggregation

  5. 5

    make one array the key and another array the value

  6. 6

    How do I create an array using the order and value from one and the key of another?

  7. 7

    Gulp - Get return value of one task from another

  8. 8

    Dynamically getting One list value with the key of another list value

  9. 9

    How to iterate through a list and while iterating, iterate through another list and replace values for upper list with inner list key value pairs

  10. 10

    How to make another key instead of replacing it in firebase

  11. 11

    Using value of members in a list as the key to another list in Tcl

  12. 12

    sbt`Task` 태그 나열

  13. 13

    How to add a key,value pair to a list?

  14. 14

    How can a key be part of value in a hash?

  15. 15

    How to increment with the new value when on duplicate key?

  16. 16

    How to remove dictionary key with known value?

  17. 17

    How to parse an JSON Empty Key Value in iOS?

  18. 18

    How to configure ssh to use different key?

  19. 19

    How to execute war task only if a property equals to a particular value

  20. 20

    How to use Format files in SSIS Data Flow task?

  21. 21

    how to call a variable value in another php file

  22. 22

    How to pass the 'self' value of a method to another method?

  23. 23

    How to pass the autocompleted value into another function?

  24. 24

    How to get the value for one function to another?

  25. 25

    how to use the output value in php

  26. 26

    How to use one function in another with classes in Python

  27. 27

    How to use my project on another computer

  28. 28

    How can I use another drive with Owncloud?

  29. 29

    CSS: Use number of a class/id as value for another class/id

뜨겁다태그

보관