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

FISH-886 Deploy GAV from local repository + some code cleanup #5035

Merged
merged 2 commits into from
Dec 18, 2020

Conversation

avpinchuk
Copy link
Contributor

@avpinchuk avpinchuk commented Dec 7, 2020

Description

Added ability to deploy GAV from local repository.

Example:
java -jar payara-micro.jar --deployFromGAV org.example:someapp:1.0 --additionalRepository file:///c:/Users/alex/.m2/repository

Important Info

Blockers

Testing

New tests

Testing Performed

Testing Environment

Zulu JDK 8, Windows 10 Pro

Documentation

Notes for Reviewers

@lprimak
Copy link
Contributor

lprimak commented Dec 7, 2020

jenkins test

@lprimak lprimak added PR: CLA CLA submitted on PR by the contributor Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev Type: Enhancement Label issue as an enhancement request labels Dec 7, 2020
@lprimak lprimak self-requested a review December 7, 2020 17:40
Copy link
Contributor

@lprimak lprimak left a comment

Choose a reason for hiding this comment

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

Please:

  • Update copyright year
  • add an example into the PR on how this can be used (example)

@avpinchuk
Copy link
Contributor Author

  • tell me please i have to change the main copyright header or add portions copyright?
  • done

@lprimak
Copy link
Contributor

lprimak commented Dec 7, 2020

Just copyright year to 2020

@avpinchuk avpinchuk requested a review from lprimak December 7, 2020 19:29
@lprimak
Copy link
Contributor

lprimak commented Dec 7, 2020

@svendiedrichsen can you review this please?

@lprimak
Copy link
Contributor

lprimak commented Dec 10, 2020

jenkins test

@AlanRoth AlanRoth changed the title Deploy GAV from local repository + some code cleanup Deploy GAV from local repository + some code cleanup / FISH-886 Dec 10, 2020
@AlanRoth AlanRoth changed the title Deploy GAV from local repository + some code cleanup / FISH-886 FISH-886 Deploy GAV from local repository + some code cleanup Dec 10, 2020
validURLFound = true;
}
} else {
HttpURLConnection httpConnection = (HttpURLConnection) artefactURL.openConnection();
Copy link
Contributor

@svendiedrichsen svendiedrichsen Dec 15, 2020

Choose a reason for hiding this comment

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

This makes some assumption about the type of connection but it might be a JarURLConnection. Like this one: jar:http://www.foo.com/bar/baz.jar.
You might want a separate if-block to handle these kind of archive URLs.
But if it is all about local URLs this is unnessessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I only needed a local repository but jar scheme support also possible

Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be decided by someone from Payara.

Copy link
Member

Choose a reason for hiding this comment

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

I'd say that's outside the scope of this PR.
I'm not immediately sure of the need to handle them either tbh - I think that functionality is covered by the standard --deploy option unless you're talking about using a Jar Url as a "maven" repository in its own right, which sounds mega-niche!

@@ -117,7 +120,7 @@
* the provided GAV as Strings
*/
private Map<String, String> splitGAV(String GAV) throws MalformedURLException {
final String[] splitGAV = GAV.split(",|:");
final String[] splitGAV = GAV.split("[,:]");
final Map<String, String> GAVMap = new HashMap<>();
try {
GAVMap.put("groupId", splitGAV[0].replace('.', '/'));
Copy link
Contributor

@svendiedrichsen svendiedrichsen Dec 15, 2020

Choose a reason for hiding this comment

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

Maven coordinates might also include packaging and classifier. If the packaging coordinate exists you don't have to iterate over the whole list of possible file extensions. You could simply use this. If the classifier coordinate exists you won't be able to find the artefact without it in the URL.
You can find some examples here: https://developpaper.com/coordinates-of-maven-basic-course/

Copy link
Contributor Author

@avpinchuk avpinchuk Dec 15, 2020

Choose a reason for hiding this comment

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

This may be implemented if we stick to some predefined format. In community doc defined artifactId, groupId and version only. Link in next answer

Copy link
Contributor

@svendiedrichsen svendiedrichsen Dec 17, 2020

Choose a reason for hiding this comment

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

Yes, its true according to the Payara doc but shouldn't there be a possibility to use packaging and qualifier? You could imagine having a build of an deplyoable artefact which builts a jar and a war of the same name. According the current code it would only be possible to deploy the jar. As this comes first in the list. The same goes for the qualifier by which you have a built which produces two jars of the same name but one has i.e. the qualifier UBER to mark the uber-jar containing all the dependencies inside. You couldn't distinguish them without using a qualifier.
You could default those two GAV components to jar and empty and would not have to iterate over the list of file suffixes. But maybe I'm just over-engineering this thing for this usecase.
This needs to be decided by someone from Payara.

Copy link
Member

Choose a reason for hiding this comment

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

Not allowing a user to specify packaging and qualifiers is simply a limitation / missing feature of the implementation at the moment - I'd say it's out of scope for this PR though. The use case you described makes sense, I just wouldn't bundle it into this PR to prevent scope creep, particularly since it isn't a trivial 1 line change.

@@ -117,7 +120,7 @@
* the provided GAV as Strings
*/
private Map<String, String> splitGAV(String GAV) throws MalformedURLException {
final String[] splitGAV = GAV.split(",|:");
final String[] splitGAV = GAV.split("[,:]");
Copy link
Contributor

@svendiedrichsen svendiedrichsen Dec 15, 2020

Choose a reason for hiding this comment

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

Isn't a valid GAV only split by :? Doesn't it suggest when you find a comma that this is really a list of GAV? And if you accept lists here you should really focus on splitting by comma first to have a chance to determine optional fields like packaging and classifier.

Copy link
Contributor Author

@avpinchuk avpinchuk Dec 15, 2020

Choose a reason for hiding this comment

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

According to documentation https://docs.payara.fish/community/docs/5.2020.7/documentation/payara-micro/deploying/deploy-cmd-line.html#deploying-applications-from-a-maven-repository for each GAV needs its own --deployFromGAV option. Or I misunderstood the documentation. Here I just replaced logical operator with a simple class

Copy link
Contributor

@svendiedrichsen svendiedrichsen Dec 17, 2020

Choose a reason for hiding this comment

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

Yes it is true for the Payara doc, but at least uncommon to use a comma nonetheless. This needs to be decided by someone from Payara.

Copy link
Member

Choose a reason for hiding this comment

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

Looking back at the commit history around this, comma was the original delimiter as that's the "default" delimiter for Payara CLI (though we do use different delimiters all over the place), and we added in support for using a colon after to be more in line with the usual Maven notation.

So fish.payara,guppy,1.0 and fish.payara:guppy:1.0 are both valid, and if you want to deploy more than one artefact you have to specify the option multiple times.

@svendiedrichsen
Copy link
Contributor

svendiedrichsen commented Dec 17, 2020

@svendiedrichsen can you review this please?

@lprimak I have done it. Someone from Payara needs to look into this to make some decisions though.

@lprimak
Copy link
Contributor

lprimak commented Dec 18, 2020

@svendiedrichsen I will take a look in the next few days, thanks!

@lprimak lprimak merged commit 6b12732 into payara:master Dec 18, 2020
lprimak pushed a commit that referenced this pull request Feb 5, 2021
…#292)

* Deploy GAV from local repository

* Change copyright year

Co-authored-by: Alexander Pinchuk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: CLA CLA submitted on PR by the contributor Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev Type: Enhancement Label issue as an enhancement request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants