Skip to content

Support for gradle builder for Java#1007

Merged
sanathkr merged 15 commits intoaws:developfrom
sanathkr:gradle-builder
Feb 18, 2019
Merged

Support for gradle builder for Java#1007
sanathkr merged 15 commits intoaws:developfrom
sanathkr:gradle-builder

Conversation

@sanathkr
Copy link
Contributor

@sanathkr sanathkr commented Feb 13, 2019

Issue #, if available:
#880

Description of changes:
This won't build until we release aws-lambda-builders library. But sending the WIP PR to get early feedback.

Checklist:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

pathlib2~=2.3.2; python_version<"3.4"
requests==2.20.1
aws_lambda_builders==0.0.5
aws_lambda_builders==0.1.0
Copy link
Contributor

Choose a reason for hiding this comment

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

0.1.0 🕺

@jfuss
Copy link
Contributor

jfuss commented Feb 13, 2019

Don't forget the java8 init templates will need updating from maven to gradle

@sanathkr
Copy link
Contributor Author

Don't forget the java8 init templates will need updating from maven to gradle

It doesn't make sense. We will let the init templates use maven and eventually provide a maven builder. Yes, meanwhile sam init && sam build won't work, but that's a short term problem

@sanathkr sanathkr changed the title WIP: Support for gradle builder for Java Support for gradle builder for Java Feb 14, 2019
@sriram-mv
Copy link
Contributor

1. Python 2.7, 3.6, 3.7\n
4. Nodejs 8.10, 6.10
4. Ruby 2.5
5. Java 8
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to call out which Dependency Managers we support?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, yeah good idea. Will do

def _build_function(self, function_name, codeuri, runtime):
config = get_workflow_config(runtime)

# Create the arguments to pass to the builder
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is floating. This seems like docstring worthy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


class BasicWorkflowSelector(object):
"""
Basic workflow selector that returns the first available configuration in the given list of configurations
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this going to be extended in the future? what is the value of this class, if its just returns the first one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For inheritance.. I didn't create an abstract base class because it didn't seem helpful. But in future we will create a new subclass that will look up Samrc to find the workflow config to use given a runtime. This can be useful for provided runtimes or if customer wants to override a default configuration

runtime,
optimizations,
options):
options,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just making sure, the protocol version is passed in by importing the builders library right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct.

process = subprocess.Popen(cmdlist, cwd=self.working_dir)
process.wait()

self._verify_built_artifact(self.default_build_dir, self.FUNCTION_LOGICAL_ID,
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 look at built artifacts verify if we used gradle or gradlew?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good point. I don't know. I will check with Dongie

try:
return workflow_config_by_runtime[runtime]
except KeyError:
if runtime not in selectors_by_runtime:
Copy link
Contributor

Choose a reason for hiding this comment

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

It's much cleaner if you do

try:
  selector = selectors_by_runtime[runtime]
  config = selector.get_config(code_dir, project_dir)
except KeyError:
  #blah 
except ValueError:
  #another blah 

Also more pythonic :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really. try/catch blocks should be scoped very tightly to the code you expect to throw. So when you know two statemtents will throw for two different reasons, I would rather have them in separte try blocks or let them throw very specific exceptions - not KeyError & ValueError. That's why I made this way.


@staticmethod
def _has_manifest(config, directory):
return os.path.exists(os.path.join(directory, config.manifest_name))
Copy link
Contributor

Choose a reason for hiding this comment

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

One day you will use pathlib.. one day..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when we move to py3. Pathlib in py2 is really confusing

If none of the supported manifests files are found
"""

# Search for manifest first in code directory and then in the project directory.
Copy link
Contributor

Choose a reason for hiding this comment

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

How this works and is resolved needs to be clearly documented (somewhere)

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 will add to the help text for now

@sriram-mv
Copy link
Contributor

I dont have any other concerns, will be nice if can determine which executable was used to build in the built artifacts. But I'm not blocking on that. will approve once build passes.

@sanathkr sanathkr merged commit 73a1569 into aws:develop Feb 18, 2019
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.

3 participants