Hi,
Using daml 2.1.1 sdk.
I have a simple template:
module Counter where
template Counter
with
owner : Party
value : Int
incrementers : [Party]
rules: [ContractId CounterRule]
where
signatory owner
observer incrementers
key owner : Party
maintainer key
choice Increment : ContractId Counter
with incrementer : Party
controller incrementer
do
create this with value = value + 1
interface CounterRule where
apply : Party → Bool
When generating the grpc java code with a daml codegen java I noticed something out of place in that the rule, is placed outside the package indicated into java command:
daml codegen java .daml/dist/counter.dar=test -o …/grpctest/src/main/java
Inside src/main/java I see 2 packages:
counter
test
In counter I see the counter rule. Yet, in test I see all the regular packages. But does not compile since it cannot find the CounterRule …
counter/Counter.java:38: error: package CounterRule does not exist
public final List<CounterRule.ContractId> rules;
^
Any clue as to what I am doing wrong?
Hi @Jean_Safar1,
I’m not very familiar with the Java codegen myself, but I know it’s been a pretty active project over the past few weeks, particularly around interface integration. Before we delve into this further, can you double-check whether you still see this issue if you use 2.2.0-snapshot.20220504.9851.0.4c8e027d
instead of 2.1.1
?
I will check with the snapshot!
It does with the example I put above
So it does or does not work with the snapshot?
Counter.daml
template Counter
with
owner : Party
value : Int
incrementers : [Party]
rules: [ContractId CounterRule]
where
signatory owner
observer incrementers
key owner : Party
maintainer key
choice Increment : ContractId Counter
with incrementer : Party
controller incrementer
do
create this with value = value + 1
interface CounterRule where
apply : Party → Bool
So that is the full daml code?
Hi @Jean_Safar1,
I can reproduce the issue. Here are specific repro steps:
daml new t
cd t
echo 'interface TestInt where' >> daml/Main.daml
echo ' f : Int -> Int' >> daml/Main.daml
echo 'build-options:' >> daml.yaml
echo ' - --target=1.dev' >> daml.yaml
daml build
daml codegen java .daml/dist/t-0.0.1.dar -o jvm1
daml codegen java .daml/dist/t-0.0.1.dar=prefix -o jvm2
Comparing the contents of jvm1
and jvm2
at that point shows that the TestInt
file ends up in the wrong place, e.g. with
$ diff <(cd jvm1; find .) <(cd jvm2/prefix; find .)
8d7
< ./main/TestInt.java
Specifically, for jvm2
, it ends up in jvm2/main/TestInt.java
instead of jvm2/prefix/main/TestInt.java
as expected.
We’ll be looking into this further. Thanks for the report!
2 Likes