Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incremental build Java generation. #16

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

hillcg-aws
Copy link
Collaborator

Translate task is requested to put generated source into a target directory "main", however dafny actually places it into a directory callled "main-java" and the translate task performs a rename at the end to compensate. The problem is this rename can fail, for example on an incremental build, when the target directory already exists.

Instead keep "main-java" as target and pass this modified target onto subsequent gradle tasks as new source to be compiled.

@Test
void convertsToJava() throws IOException {
var dir = new File("examples/java");
// N.B. Theis path is set in DafnyPlugin.java, then Dafny adds "-java" suffix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// N.B. Theis path is set in DafnyPlugin.java, then Dafny adds "-java" suffix
// N.B. This path is set in DafnyPlugin.java, then Dafny adds "-java" suffix

Copy link
Member

@robin-aws robin-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just a couple of nits

@@ -0,0 +1,5 @@
module Foo {
datatype Bar = create(baz: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
datatype Bar = create(baz: string) {
datatype Bar = Create(baz: string) {

nit: Dafny style guide says to use PascalCase for Datatype

Translate task is requested to put generated source into a target
directory "main", however dafny actually places it into a directory
callled "main-java" and the translate task performs a rename at the
end to compensate. The problem is this rename can fail, for example
on an incremental build, when the target directory already exists.

Instead keep "main-java" as target and pass this modified target
onto subsequent gradle tasks as new source to be compiled.
Copy link
Member

@robin-aws robin-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@robin-aws robin-aws merged commit 969ccc6 into dafny-lang:main Jan 7, 2025
1 check passed
@hillcg-aws hillcg-aws deleted the inc-build branch January 7, 2025 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants