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

Cobigen CLI commandlet #273

Merged
merged 17 commits into from
Jan 14, 2020
Merged

Cobigen CLI commandlet #273

merged 17 commits into from
Jan 14, 2020

Conversation

jdiazgon
Copy link
Member

@jdiazgon jdiazgon commented Oct 11, 2019

Addressing #59. This PR adds a new commandlet capable of installing the CobiGen CLI inside of the ide.

Ready to be merged.

doRunCommand "unzip -q '${COBIGEN_CLI_HOME}/${software_name}.jar' 'cg.sh' -d '${COBIGEN_CLI_HOME}'"
doRunCommand "unzip -q '${COBIGEN_CLI_HOME}/${software_name}.jar' 'class-loader-agent.jar' -d '${COBIGEN_CLI_HOME}'"
fi

Copy link
Member

Choose a reason for hiding this comment

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

The "doIsWindows" is a bit misleading name: It (currently) results in "yes", when the local bash environment is either msys (typically installed by git-for-windows) or cygwin. But both those firewalls need the *.sh files, when cobigen shall be started from inside the environment. In addition to that, the *.bat may also help - but only, when a developer also uses windows-CMD.

It might be easiest to extract just all files in any case.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, when we install maven or other multi-platform tools, we just extract everything.
Cant you just use doInstall function for cobigen as well?

Copy link
Member Author

@jdiazgon jdiazgon Oct 16, 2019

Choose a reason for hiding this comment

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

Unfortunately I cannot use doInstall as my .jar extension is not on the list of compatible files for doExtract (that method is called inside doInstall)

Also that doExtract would extract other useless files.

Copy link
Member

Choose a reason for hiding this comment

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

I can support .jar in doExtract in a second. Why do you have "useless" files in your CLI release?
Can you change the way you bundle the release? (we do not have to block this PR now, but on the long run I would prefer cleaning this code as it appears odd to me).
Further the content of this JAR is designed/defined in CobiGen but here you are spreading redundant knowledge about it. What if some day CobiGen decides to rename or replace class-loader-agent.jar? Then this will break and nobody will notice as the CobiGen team is not anymore aware about this dependency in another repo...

Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

@jdiazgon thanks for this PR already. I wont approve or merge already as you said. Generally this is looking good but what is confusing me is:

  • why does devon cobigen not support any other arguments? E.g. for maven you can not only install it via devon mvn setup but also invoke it via devon mvn «args» instead of mvn «args». My expectation of cobigen commandlet would be the same.
  • why do you distribute cobigen CLI as JAR if it technically is a software bundle containing even shell scripts like cg.sh that need executable permissions? IMHO you should distribute it as *.tgz and set permissions accordingly.

doRunCommand "unzip -q '${COBIGEN_CLI_HOME}/${software_name}.jar' 'cg.sh' -d '${COBIGEN_CLI_HOME}'"
doRunCommand "unzip -q '${COBIGEN_CLI_HOME}/${software_name}.jar' 'class-loader-agent.jar' -d '${COBIGEN_CLI_HOME}'"
fi

Copy link
Member

Choose a reason for hiding this comment

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

Yes, when we install maven or other multi-platform tools, we just extract everything.
Cant you just use doInstall function for cobigen as well?

scripts/src/main/resources/scripts/devon.properties Outdated Show resolved Hide resolved
scripts/src/main/resources/scripts/functions Outdated Show resolved Hide resolved
@hohwille hohwille changed the title Cobigen CLI commandlet WIP: Cobigen CLI commandlet Oct 14, 2019
@hohwille hohwille added commandlet related to commandlets (scripts/command/*) enhancement New feature or request java related to Java code, the Java Virtual Machine and directly related tooling (OpenJDK, Adoptium) maven related to apache maven build tool scripts related to shell scripts (bash and CMD) labels Oct 14, 2019
@hohwille hohwille added this to the release:3.2.0 milestone Oct 14, 2019
@jdiazgon
Copy link
Member Author

Thanks for the feedback! I will update it as soon as possible.

why do you distribute cobigen CLI as JAR? IMHO you should distribute it as *.tgz and set permissions accordingly

Seems a good idea! I think I will implement it for the next release as we are already on a hurry for the current version and I don't have time for new changes.

@maybeec
Copy link
Member

maybeec commented Oct 22, 2019

I am not sure whether I got it right, but cobigen-cli is a runnable jar, so you cannot just release it as it tar.gz or something like this. @jdiazgon as far as I remember, we simply extract a pom.xml file to dynamically download other dependencies, nothing more right?

@jdiazgon
Copy link
Member Author

jdiazgon commented Oct 23, 2019

we simply extract a pom.xml file to dynamically download other dependencies

That was right for the previous version. However, for JDK 11 I had to add a Java agent as the class loading has completely changed. Right now our runnable jar contains that pom.xml and the jar of the Java agent.

@maybeec
Copy link
Member

maybeec commented Oct 25, 2019

@jdiazgon the java11 compatibility is fixed, right? so this could be merged?

@jdiazgon
Copy link
Member Author

the java11 compatibility is fixed, right? so this could be merged?

It is fixed but we should not merged yet as the download URL is not the correct one. Please see this.

Also the Travis build is failing with the following error:

In scripts/command/cobigen line 35:
  doEcho "Running: ${cobigen_cmd} ${@}"
                                  ^--^ SC2145: Argument mixes string and array. Use * or separate argument.
In scripts/command/cobigen line 41:
    "${cobigen_cmd}" "${@} --verbose"
                      ^--^ SC2145: Argument mixes string and array. Use * or separate argument.

It seems a Linux related error. I will fix it ASAP.

@markusschuh
Copy link
Member

With respect to

In scripts/command/cobigen line 35:
  doEcho "Running: ${cobigen_cmd} ${@}"
                                  ^--^ SC2145: Argument mixes string and array. Use * or separate argument.
In scripts/command/cobigen line 41:
    "${cobigen_cmd}" "${@} --verbose"
                      ^--^ SC2145: Argument mixes string and array. Use * or separate argument.

The findings of shellcheck (which is run as part of travis) are correct ones. An explanatory URL is available within the travis build details.

I'd say, the correct fixes were to use the following code instead:

  doEcho "Running: ${cobigen_cmd} ${*}"
. . .
    "${cobigen_cmd}" --verbose "${@}"

This is not only true for linux but for bash scripts on any platform.

Copy link
Member

@markusschuh markusschuh left a comment

Choose a reason for hiding this comment

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

Everything looks o.k. now to me.
Or more precise: Everything about the shell syntax. There had been other comments on / requests for this PR which I have not reviewed all for being fulfilled or not.

@jdiazgon jdiazgon changed the title WIP: Cobigen CLI commandlet Cobigen CLI commandlet Jan 12, 2020
@jdiazgon
Copy link
Member Author

Besser spät als nie. This PR is ready to be merged as the CobiGen CLI has been released to public.

@maybeec
Copy link
Member

maybeec commented Jan 12, 2020

@hohwille if this PR is fine for you as well now, please merge it.

@jdiazgon
Copy link
Member Author

The link which should download the latest version of the CLI is returning 404:

https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.devonfw.cobigen&a=cli&v=LATEST

We guess that Maven Central needs to refresh its metadata and it will take some hours to be available. However, I released yesterday and it should have been enough time. IMHO, if in 3 hours it is not yet working, we should go for a URL that works like:

https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.devonfw.cobigen&a=cli&v=1.0.1

@jdiazgon
Copy link
Member Author

I had to change the "LATEST" URL as it was not working yet. PR ready to be merged.

@maybeec
Copy link
Member

maybeec commented Jan 14, 2020

@jdiazgon, the LATEST link is working now.

This reverts commit d8a17d4 which changed the download URL.
Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

Hey all. To me this is good enough to be merged. I still have some comments I would like to have reworked/improved in the future. Further I would like to kindly ask you to update the PR comments.
Thanks for your effort on this and all CobiGen. 👍

doRunCommand "unzip -q '${COBIGEN_CLI_HOME}/${software_name}.jar' 'cg.sh' -d '${COBIGEN_CLI_HOME}'"
doRunCommand "unzip -q '${COBIGEN_CLI_HOME}/${software_name}.jar' 'class-loader-agent.jar' -d '${COBIGEN_CLI_HOME}'"
fi

Copy link
Member

Choose a reason for hiding this comment

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

I can support .jar in doExtract in a second. Why do you have "useless" files in your CLI release?
Can you change the way you bundle the release? (we do not have to block this PR now, but on the long run I would prefer cleaning this code as it appears odd to me).
Further the content of this JAR is designed/defined in CobiGen but here you are spreading redundant knowledge about it. What if some day CobiGen decides to rename or replace class-loader-agent.jar? Then this will break and nobody will notice as the CobiGen team is not anymore aware about this dependency in another repo...

@hohwille hohwille merged commit 968e35a into devonfw:master Jan 14, 2020
@hohwille
Copy link
Member

Not entirely complete. See:
#59 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commandlet related to commandlets (scripts/command/*) enhancement New feature or request java related to Java code, the Java Virtual Machine and directly related tooling (OpenJDK, Adoptium) maven related to apache maven build tool scripts related to shell scripts (bash and CMD)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants