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 Gradle build support, initial version (fixes #118) #121

Merged
merged 5 commits into from
May 15, 2018

Conversation

vorburger
Copy link
Collaborator

No description provided.

Copy link
Contributor

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

tbh, I'm not a Gradle user at all, so its probably hard for me to support this feature on the long run.

If there are others (@dhirajsb @jamesnetherton ...) willing to support this, I'm happy to integrate the PR.

added some minor comments, too.

BTW, what would you think to add some real shell integration tests with bats, like we do for https://github.com/fabric8io-images/run-java-sh ?


# Normalize dir
# TODO how do you get this to check not one but two (../..) up?
# dir=$(echo ${dir} | tr -s /)
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this section supposed to do ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it was inspired by the equivalent for Maven, but things work without this (as proven by java/examples/gradle in upcoming PR), so I've just removed in the new clean-up commit; hope that's OK? It could always be added back later (and covered by the example / test), if really needed.

@@ -111,6 +136,10 @@ function setup_maven() {
fi
}

function setup_gradle() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove it for now if not used ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup, sure, makes sense; so done now in new clean up commit. PS: Just for future reference, see Gradle doc re. proxies - this would have to do something like that, similarly to function setup_maven(), I guess.

local gradle_args=${GRADLE_ARGS:-build -x test}

# If there is no user provided GRADLE_OPTS, use options from run-java.sh
if [ -f ${RUN_JAVA_DIR}/run-java.sh -a -z "${GRADLE_OPTS}" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

using [ .... ] && [ .... ] proved to be more robust to me. -a fails in certain edge case (which I dont remember right now ;-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately my bash foo smartness is not nearly good enough 😃 to understand what exactly you mean here, but FYI I've just copy/pasted this from an almost identical line in build_maven() ... perhaps you would like to raise a follow-up PR, when this is in, to adjust both this and the original that I got inspired from for this however you see fit?

export GRADLE_OPTS=$(${RUN_JAVA_DIR}/run-java.sh options)
fi

if [ ! -z "${GRADLE_OPTS}" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

-n ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

similarly to above, build_maven() uses if [ ! -z "${MAVEN_OPTS}" ]; then - this should probably be kept consistent, and changed in both places, in a separate PR when this is in? I can raise one proposing that as a follow-up to this - if you would like?


# ======================
# TODO Remove repo if desired
# if [ "x${MAVEN_CLEAR_REPO}" != "x" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Why commented out ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've un-commented it in the final clean-up commit now, using GRADLE_CLEAR_REPO and ${S2I_ARTIFACTS_DIR}/gradle, in anticipation of related future work under #150 ... OK?

@jamesnetherton
Copy link
Contributor

If we are going to support Gradle then we should restrict its implementation to the community images initially.

@dhirajsb
Copy link
Contributor

agree with @jamesnetherton

@vorburger
Copy link
Collaborator Author

@rhuss I'm hoping to be able to make time to pick this up after my other pending PRs are in; the idea would be to cover this using my new self testing approach for this example as well.

@jamesnetherton @dhirajsb sure OK for me initially community images only; so I'll put a big IFF into the respective templates - OK for you as well @rhuss ?

@rhuss
Copy link
Contributor

rhuss commented Apr 29, 2018

@vorburger yes, sounds like a plan. I'm still a bit hesitant ans I'm not sure how good we can support the Gradle support in case of an error, but hey, let's try it ;-)

Copy link
Collaborator Author

@vorburger vorburger left a comment

Choose a reason for hiding this comment

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

@rhuss as per more detailed in-line comments, I've reacted to all of your review feedback.

@jamesnetherton @dhirajsb @rhuss the (hopefully) last commit in this PR restricts the implementation to the community image by a bunch of {{? fp.param.base != "rhel"}} in the template - OK for you?


# Normalize dir
# TODO how do you get this to check not one but two (../..) up?
# dir=$(echo ${dir} | tr -s /)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it was inspired by the equivalent for Maven, but things work without this (as proven by java/examples/gradle in upcoming PR), so I've just removed in the new clean-up commit; hope that's OK? It could always be added back later (and covered by the example / test), if really needed.

@@ -111,6 +136,10 @@ function setup_maven() {
fi
}

function setup_gradle() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup, sure, makes sense; so done now in new clean up commit. PS: Just for future reference, see Gradle doc re. proxies - this would have to do something like that, similarly to function setup_maven(), I guess.

local gradle_args=${GRADLE_ARGS:-build -x test}

# If there is no user provided GRADLE_OPTS, use options from run-java.sh
if [ -f ${RUN_JAVA_DIR}/run-java.sh -a -z "${GRADLE_OPTS}" ]; then
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately my bash foo smartness is not nearly good enough 😃 to understand what exactly you mean here, but FYI I've just copy/pasted this from an almost identical line in build_maven() ... perhaps you would like to raise a follow-up PR, when this is in, to adjust both this and the original that I got inspired from for this however you see fit?

export GRADLE_OPTS=$(${RUN_JAVA_DIR}/run-java.sh options)
fi

if [ ! -z "${GRADLE_OPTS}" ]; then
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

similarly to above, build_maven() uses if [ ! -z "${MAVEN_OPTS}" ]; then - this should probably be kept consistent, and changed in both places, in a separate PR when this is in? I can raise one proposing that as a follow-up to this - if you would like?


# ======================
# TODO Remove repo if desired
# if [ "x${MAVEN_CLEAR_REPO}" != "x" ]; then
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've un-commented it in the final clean-up commit now, using GRADLE_CLEAR_REPO and ${S2I_ARTIFACTS_DIR}/gradle, in anticipation of related future work under #150 ... OK?

Copy link
Contributor

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

lgtm. Haven't really tested a gradel build, but I'm confident @vorburger will help us if there should be an issue.

BTW, @vorburger I added you with write access to this repo so that you then can work on and fix Gradle issues ;-P

@rhuss rhuss merged commit 88da4d8 into fabric8io-images:master May 15, 2018
@vorburger
Copy link
Collaborator Author

BTW, @vorburger I added you with write access to this repo so that you then can work on and fix Gradle issues ;-P

OK, cool - will do my best!

@maslick
Copy link

maslick commented Mar 19, 2019

running s2i with -e GRADLE_CLEAR_REPO=true has no effect on the image size:

s2i build https://github.com/maslick/see-i-see-d.git#jdk11 fabric8/s2i-java:latest-java11 vesna:jdk11 -e GRADLE_CLEAR_REPO=true

I'm not sure but seems this if clause doesn't do anything:

# ======================
  # Remove repo if desired
  if [ "x${GRADLE_CLEAR_REPO}" != "x" ]; then
    rm -rf "${S2I_ARTIFACTS_DIR}/gradle"
    check_error "Cannot remove local Gradle repository ${S2I_ARTIFACTS_DIR}/gradle" $?
  fi

Instead it should have been:

if [ "x${GRADLE_CLEAR_REPO}" != "x" ]; then
    rm -rf "${S2I_SOURCE_DIR}"
    check_error "Cannot remove local Gradle repository ${S2I_SOURCE_DIR}" $?
  fi

@rhuss
Copy link
Contributor

rhuss commented Mar 22, 2019

@vorburger could you please have a look ?

@vorburger
Copy link
Collaborator Author

@maslick sorry I don't really have the time to help with this project anymore, but if you'd like to raise a PR putting what you are suggesting above into code, then perhaps someone will help to review and merge it.

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

Successfully merging this pull request may close these issues.

5 participants