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

maven plugin should install maven build-package #812

Open
vpa1977 opened this issue Aug 15, 2024 · 5 comments
Open

maven plugin should install maven build-package #812

vpa1977 opened this issue Aug 15, 2024 · 5 comments
Labels
Bug Something isn't working Triaged

Comments

@vpa1977
Copy link
Contributor

vpa1977 commented Aug 15, 2024

Bug Description

maven plugin does not install maven build-package.
In order to use maven plugin the image should have maven installed already which is inconvenient.
Would it be possible to append

  build-packages:
      - maven
      - openjdk-21-jdk-headless

if the part does not contain 'build-packages'

To Reproduce

  1. create a rockcraft application with a maven part.
  2. rockcraft pack

part yaml

application:
    plugin: maven
    source: sample
    source-type: local

Relevant log output

2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.441 plugin validation command: 'mvn --version'
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.443 Environment validation failed for part 'application': 'mvn' not found and part 'application' does not depend on a part named 'maven-deps' that would satisfy the dependency.
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444 Traceback (most recent call last):
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_parts/plugins/validator.py", line 101, in validate_dependency
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444     output = self._execute(command).strip()
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_parts/plugins/validator.py", line 145, in _execute
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444     proc = subprocess.run(
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444   File "/snap/rockcraft/2374/usr/lib/python3.10/subprocess.py", line 526, in run
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444     raise CalledProcessError(retcode, process.args,
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444 subprocess.CalledProcessError: Command '['/bin/bash', '/tmp/tmpx0rd72pf']' returned non-zero exit status 127.
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444 The above exception was the direct cause of the following exception:
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444 Traceback (most recent call last):
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_application/services/lifecycle.py", line 256, in run
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444     with self._lcm.action_executor() as aex:
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_parts/executor/executor.py", line 304, in __enter__
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444     self._executor.prologue()
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_parts/executor/executor.py", line 91, in prologue
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444     self._verify_plugin_environment()
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.444   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_parts/executor/executor.py", line 290, in _verify_plugin_environment
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.445     validator.validate_environment(part_dependencies=part.dependencies)
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.445   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_parts/plugins/maven_plugin.py", line 64, in validate_environment
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.445     version = self.validate_dependency(
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.445   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_parts/plugins/validator.py", line 118, in validate_dependency
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.445     raise errors.PluginEnvironmentValidationError(
2024-08-16 11:32:31.728 :: 2024-08-16 11:32:31.445 craft_parts.errors.PluginEnvironmentValidationError: Environment validation failed for part 'application': 'mvn' not found and part 'application' does not depend on a part named 'maven-deps' that would satisfy the dependency.
2024-08-16 11:32:31.729 Executing on host: lxc --project rockcraft config device show local:rockcraft-maven-sample-chisel-on-amd64-for-amd64-61079577
2024-08-16 11:32:31.820 Executing on host: lxc --project rockcraft config device remove local:rockcraft-maven-sample-chisel-on-amd64-for-amd64-61079577 disk-/root/project
2024-08-16 11:32:31.954 Executing on host: lxc --project rockcraft stop local:rockcraft-maven-sample-chisel-on-amd64-for-amd64-61079577
2024-08-16 11:32:35.883 Failed to execute rockcraft in instance.
2024-08-16 11:32:35.885 Traceback (most recent call last):
2024-08-16 11:32:35.885   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_application/application.py", line 376, in run_managed
2024-08-16 11:32:35.885     instance.execute_run(  # pyright: ignore[reportUnknownMemberType,reportUnknownVariableType]
2024-08-16 11:32:35.885   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_providers/lxd/lxd_instance.py", line 293, in execute_run
2024-08-16 11:32:35.885     return self.lxc.exec(
2024-08-16 11:32:35.885   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_providers/lxd/lxc.py", line 387, in exec
2024-08-16 11:32:35.885     return runner(final_cmd, timeout=timeout, check=check, **kwargs)
2024-08-16 11:32:35.885   File "/snap/rockcraft/2374/usr/lib/python3.10/subprocess.py", line 526, in run
2024-08-16 11:32:35.885     raise CalledProcessError(retcode, process.args,
2024-08-16 11:32:35.885 subprocess.CalledProcessError: Command '['lxc', '--project', 'rockcraft', 'exec', 'local:rockcraft-maven-sample-chisel-on-amd64-for-amd64-61079577', '--cwd', '/root/project', '--', 'env', 'CRAFT_MANAGED_MODE=1', 'DEBIAN_FRONTEND=noninteractive', 'DEBCONF_NONINTERACTIVE_SEEN=true', 'DEBIAN_PRIORITY=critical', 'CRAFT_PLATFORM=amd64', 'CRAFT_VERBOSITY_LEVEL=BRIEF', 'rockcraft', 'pack']' returned non-zero exit status 1.
2024-08-16 11:32:35.885 
2024-08-16 11:32:35.885 The above exception was the direct cause of the following exception:
2024-08-16 11:32:35.885 Traceback (most recent call last):
2024-08-16 11:32:35.885   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_application/application.py", line 541, in run
2024-08-16 11:32:35.885     self.run_managed(platform, build_for)
2024-08-16 11:32:35.885   File "/snap/rockcraft/2374/lib/python3.10/site-packages/craft_application/application.py", line 383, in run_managed
2024-08-16 11:32:35.885     raise craft_providers.ProviderError(
2024-08-16 11:32:35.885 craft_providers.errors.ProviderError: Failed to execute rockcraft in instance.
2024-08-16 11:32:35.885 Full execution log: '/home/vladimirp/.local/state/rockcraft/log/rockcraft-20240816-113034.715917.log'
@vpa1977 vpa1977 added the Bug Something isn't working label Aug 15, 2024
@tigarmo
Copy link
Contributor

tigarmo commented Aug 16, 2024

This is done on purpose; the idea is to give flexibility on the version of maven/jdk that you use for building the project. As you mentioned, the solution in the general case is to include those build-packages.

@lengau lengau added the Triaged label Aug 17, 2024
@lengau
Copy link
Contributor

lengau commented Aug 17, 2024

We should probably change this to behave like the rust plugin - If there's no maven-deps we install the system maven.

Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3257.

This message was autogenerated

@vpa1977
Copy link
Contributor Author

vpa1977 commented Aug 18, 2024

We should probably change this to behave like the rust plugin - If there's no maven-deps we install the system maven.

Yes, it would be nice.
Also maven depends on default-jre-headless, so we might want to have default-jdk-headless in build-packages too to deploy command line tools.

@vpa1977
Copy link
Contributor Author

vpa1977 commented Aug 20, 2024

Alternative is to make this change rockcraft-only

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

No branches or pull requests

3 participants