-
Notifications
You must be signed in to change notification settings - Fork 317
Control file placeholders not expanded correctly #822
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
Comments
Thanks for reporting. IIUC the maven variable expansion is not applied as you would expect. |
Hi @tcurdt, thank you for the quick feedback. Sorry
|
Hi @tcurdt, to help in debugging this issue I created a minimal reproducible example here: https://github.com/mattdibi/jdeb-minimal-example |
Thanks for that! I think the best next step would be to create an integration test. Similar to this one https://github.com/tcurdt/jdeb/tree/master/src/it/project-build-outputTimestamp |
It's a little odd. But it's been a while since I last look into that. https://github.com/tcurdt/jdeb/blob/master/src/main/java/org/vafer/jdeb/maven/DebMojo.java#L85 I suspect this must be a tiny fix - but it probably is more of a maven question to fix it. |
Here you go: #823 This is in no way perfect but reproduces the issue I found. I wonder if it's possible to trigger it without the need for an external plugin 🤔 P.s. I'm not a groovy expert therefore the
Not quite clear to me: are you saying that this is caused by maven? |
Thanks for the test! That should make it much easier to figure out.
In a way. These are maven properties. It seems a little strange when a plugin would have to manually resolve them. So I think there must be a way for the plugin to
but it's been a long time since I worked with maven on that level. We either need to find someone that is more into the maven plugin API or we look at how other plugins (ideally official maven plugins) are doing it. Asking on the dev list (or chat) might also be a good way to figure this out. |
Writing here some more observations/experiments (I'm not a maven expert therefore I might write stuff that is obvious to you but bear with me :D): I logged the content of the maven properties at Source changesdiff --git a/src/main/java/org/vafer/jdeb/maven/DebMojo.java b/src/main/java/org/vafer/jdeb/maven/DebMojo.java
index 0bd1daf..cb52e23 100644
--- a/src/main/java/org/vafer/jdeb/maven/DebMojo.java
+++ b/src/main/java/org/vafer/jdeb/maven/DebMojo.java
@@ -526,6 +526,8 @@ public class DebMojo extends AbstractMojo {
final VariableResolver resolver = initializeVariableResolver(new HashMap<String, String>(), outputTimestampMs);
+ getLog().info(((Map) getProject().getProperties()).toString());
+
final File debFile = new File(Utils.replaceVariables(resolver, deb, openReplaceToken, closeReplaceToken));
final File controlDirFile = new File(Utils.replaceVariables(resolver, controlDir, openReplaceToken, closeReplaceToken));
final File installDirFile = new File(Utils.replaceVariables(resolver, installDir, openReplaceToken, closeReplaceToken));
We can see that Given that the content of 🤔 What do you think @tcurdt is this approach correct? |
That really works? I am a little confused without debugging this. I don't see how.
This topic reminds me a little of the PR #148
The question is whether there is a way for maven to do the expansion or not. If there really is no maven way of doing that (and it would be good to confirm that), it should probably be a new |
Ah - now I see you have already added the Plexus code for it in the PR. That's what made it work. |
This looks like a more correct implementation than what is in the PR. |
Actually yeah, the use-case is almost identical. I didn't notice this PR before.
I tried a little but I'm having trouble finding the best approach here. Do you have any suggestion? |
I would suggest moving the VariableResolver implementation into it's own class (if easily possible that is). Before we didn't really have to deal with that. So I don't think there is a good unit test to look at in the jdeb code base. While not ideal I could also live with some integration tests though. The variable expansion has slowly grown to one of most messiest area. |
Thanks for the pointers! that's what I needed. I'll take a look at this in the next days (most probably next weekend) :) |
Hello there @tcurdt, as promised I refactored the code and added unit tests. The main change is the fact that I moved the This allows for easy testing of the variable expansion part of the old Feedback welcome! :) |
* test: add baseline * test: trigger issue * test: verify control file content * test: remove debug prints * fix: issue #822 * refactor: move initializeVariableResolver into MapVariableResolver builder * refactor: remove unnecessary arguments * refactor: remove unused imports * test: initial sanity check unit test * test: more comprehensive testing * test: refactor for easier readability * test: added nested meta property * test: add system properties interpolation test * test: minor fixes * style: retab * style: consistent use of "this" * style: fix copyright header year * test: add test case for optional properties * test: add test case with minimal data * test: improved naming convention * feat: add some error handling * refactor: remove getMap()
Uh oh!
There was an error while loading. Please reload this page.
Hello there!
I'm using
jdeb
version 1.12 to generate debian packages for our project. I have encountered an issue similar to this SO question here.I need to generate the Debian version depending on the selected Maven profile. Therefore I have:
Where
${git.commit.id.abbrev}
and${release.version}
are set by two other Maven plugins in theinitialize
phase. Essentially we have a Maven CLI parameter that allows us to select the build type:X.X.X~gitYYYYMMDDHHMM.ZZZZZZZ-1
X.X.X-1
.In the control file we have:
The resulting control file is not correct
Is this expected?
If I expand the placeholders using (for example)
maven-resources-plugin
everything works, therefore the variables are populated correctly at the timejdeb
generates the control file. Same goes when usingjdeb
'ssnapshotExpand
/snapshotTemplate
: the variable are expanded properly (unfortunately thesnapshotTemplate
option is not viable for our development model).I'm quite confused by this behaviour.
The text was updated successfully, but these errors were encountered: