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

Add modulePath field in java.test.config #1101

Closed
Empressia opened this issue Nov 14, 2020 · 8 comments · Fixed by #1329
Closed

Add modulePath field in java.test.config #1101

Empressia opened this issue Nov 14, 2020 · 8 comments · Fixed by #1329

Comments

@Empressia
Copy link

Empressia commented Nov 14, 2020

環境

  • VSCode 1.51.1
  • Windows 10 Pro

『build/module/』に依存関係にあるモジュールを配置しています。

問題

テスト用に、以下のように設定していますが、
settings.json

{
	"java.test.config": [
		{
			"name": "t",
			"vmArgs": ["--module-path", "bin/main/;build/module/"],
		}
	],
	"java.test.defaultConfig": "t"
}

テストを実行すると、以下のようなメッセージが出て、失敗してしまいます。

Error occurred during initialization of boot layer
java.lang.module.FindException: Module RequiredModule not found, required by MyModule

その他

なお、テストではない、通常の起動設定では、以下のように設定していて、正常に動作しています。
launch.json

		{
			"type": "java",
			"name": "Debug (Launch) - Current File",
			"request": "launch",
			"mainClass": "${file}",
			"modulePaths": [
				"bin/main/",
				"build/module/"
			]
		},

いろいろ試していると、vmArgs自体は、テスト実行時に、反映されているようなので、
"--module-path"が後続のオプションで上書きされているのかわかりませんが、無効化されているように見えます。

指定の仕方に問題があるのでしょうか……。

@Empressia Empressia changed the title vmArgs with "--module-path "--module-path" in vmArgs is ignored. Nov 14, 2020
@jdneo
Copy link
Member

jdneo commented Nov 15, 2020

@Empressia Would you mind to share a sample project for this issue?

@Empressia
Copy link
Author

@jdneo 簡単なのを作ってみました。これでどうでしょうか。
https://github.com/Empressia/VSCodeJavaTest01

@jdneo jdneo added the bug label Dec 21, 2020
@jdneo jdneo removed the bug label May 10, 2021
@jdneo jdneo added this to the 0.30.0 milestone May 10, 2021
@jdneo
Copy link
Member

jdneo commented May 10, 2021

Closed and tracked by #1199. A rough idea is to fully honor the launch configuration of Debugger for Java thus the user can set modulepaths separately in the setting.

@jdneo
Copy link
Member

jdneo commented May 10, 2021

@Empressia Will it work for you if Debugger expose a setting to specify modulePaths in the workspace setting?

And another question, in your case, will you need to configure multiple different modulePaths when running towards different cases?

@Empressia
Copy link
Author

回答になるかわかりませんが、デバッガーはmodulePathを生成していると考えています。
Gradleから正しく検出されてmodulePathが構成されるのが理想です。

検出しないのであれば、差分を追加設定する必要があります。
現在は、vmArgsにmodule-pathを設定すると、両方が有効になるのではなく、片方だけが有効になってしまいます。
よって、ユーザーが指定したものと、検出したものを、同時に設定する機能が少なくとも必要だと考えます。


I don't know if it will be an answer, but I think the debugger is generating a modulePath.
The ideal is to be detected from Gradle. And it's set on --module-path.

If you don't want to detect it from gradle correctly, you're going to need to set additional differences.
Currently, if I set module-path to vmArgs, only one of them will be enabled instead of both.
Therefore, I think that I need at least the function of setting what the user specified and what is detected at the same time.

@jdneo
Copy link
Member

jdneo commented May 11, 2021

It's because sometime, for some reason, the upstream buildship could not resolve the module path correctly. So in that case, you need to provide the module path to manually correct them.

The reason I ask this question is to figure out which extension should own this setting. It makes more sense to be owned by debugger because it's debugger to run the tests at the end(the test runner is just resolve the launch configuration and pass it to the debugger).

But if the module path setting is provided by debugger and test runner leverage that setting, a limitation is that the user can only have one modulepath setting per workspace. (I'm not sure if there are cases that a project needs to have different module paths when running different test cases)

@Empressia
Copy link
Author

短く回答します。

あなたが言うとおりの理由で、わたしは、モジュールパスを指定する必要があり、
わたしは、この設定を"java.test.config"で行うべきだと考えていました。
これが、デバッガーの設定なのか、テストランナーの設定なのかは、認識できていません。


I will answer short.

For the reasons you say, I need to specify a module path,
I thought this should be done with "java.test.config".
I don't know if this is a debugger setting or a test runner setting.

@jdneo jdneo reopened this Oct 25, 2021
@jdneo jdneo changed the title "--module-path" in vmArgs is ignored. Add modulePath in java.test.config Nov 2, 2021
@jdneo jdneo changed the title Add modulePath in java.test.config Add modulePath field in java.test.config Nov 2, 2021
@jdneo jdneo modified the milestones: 0.30.0, 0.33.0 Nov 2, 2021
@jdneo
Copy link
Member

jdneo commented Nov 22, 2021

End game verification steps:

  1. Download this project: https://github.com/Empressia/VSCodeJavaTest01
  2. Update java.test.config in settings.json:
"java.test.config": [
		{
			"name": "t",
			"modulePaths": ["${workspaceFolder}/bin/main", "${workspaceFolder}/module/"],
		}
	],
  1. Run Test01Tests.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants