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

Gradle support for agent does not work. #44

Closed
michael-simons opened this issue Jun 14, 2021 · 3 comments · Fixed by #47
Closed

Gradle support for agent does not work. #44

michael-simons opened this issue Jun 14, 2021 · 3 comments · Fixed by #47
Labels
bug Something isn't working

Comments

@michael-simons
Copy link

Running

./gradlew -Pagent test   

followed by

./gradlew -Pagent nativeTest

does not work but ends with

> Task :nativeTestBuild FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':nativeTestBuild'.
> Agent output missing while `agent` option is set.
  Did you run the test task before with `-Pagent` enabled?

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

even though native files are generated:

 tree build/native 
build/native
└── agent-output
    └── test
        ├── jni-config.json
        ├── proxy-config.json
        ├── reflect-config.json
        ├── resource-config.json
        └── serialization-config.json

however the plugin tries to resolve

public static final String AGENT_OUTPUT_FOLDER = Paths.get(NATIVE_IMAGE_OUTPUT_FOLDER, "agent-output").toString();
with

return project.getBuildDir().toPath().resolve(Utils.NATIVE_IMAGE_OUTPUT_FOLDER);

which is wrong in two places:

The test path is not in there but the native path will be resolved twice.

Moving the agent files into

tree build/native/native 
build/native/native
└── agent-output
    └── test
        ├── jni-config.json
        ├── proxy-config.json
        ├── reflect-config.json
        ├── resource-config.json
        └── serialization-config.json

"fixes" this…

@jarpz
Copy link

jarpz commented Jun 16, 2021

Hi, Im getting the same error with 0.9.0 version

> Task :nativeTestBuild FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':nativeTestBuild'.
> Agent output missing while `agent` option is set.
  Did you run the test task before with `-Pagent` enabled?

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

My config:

plugins {
id 'org.graalvm.buildtools.native' version "0.9.0"

}
nativeTest {
    agent = true
    persistConfig = true
}

The folder src/main/resources/META-INF/native-image is already created.

is there a workaround?

@gradinac
Copy link
Contributor

Hey @jarpz! As a workaround for 0.9, could you try the running the tests like this:

./gradlew -Pagent nativeTest -DpersistConfig

@jarpz
Copy link

jarpz commented Jun 17, 2021

Hey @jarpz! As a workaround for 0.9, could you try running the tests like this:

./gradlew -Pagent nativeTest -DpersistConfig

We got this:

WARNING: Could not resolve org.gradle.api.internal.tasks.testing.junit.AbstractJUnitSpec for serialization configuration.
Error: Cannot find serialization target class org.Gradle.api.internal.tasks.testing.junit.AbstractJUnitSpec. The missing of this class can't be ignored even if -H:+AllowIncompleteClasspath is set. Please make sure it is in the classpath
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Error: Image build request failed with exit status 1

I know we can customize the build but the problem is in the reflection-config.json, which are been including tests classes.

Is that right?

Also, the generated files are put in test/resources/** folder. those files are put in the main/resources/**, are they?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants