[ 
https://issues.apache.org/jira/browse/PIG-4417?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14338578#comment-14338578
 ] 

Akshay Rai commented on PIG-4417:
---------------------------------

h3.Updates and changes: (Ignore my first comment)

All the existing Register commands like registering a Jar/script from local 
system or from hdfs will continue to work as before. I will be documenting an 
extension to the Register command to download artifacts and dependencies 
automatically from repositories and loading them to the classpath.

h4.Registering an Artifact:
To download an Artifact (and its dependencies) we need to specify the artifact 
following the below syntax. I am using Grape to download the artifact and its 
dependencies. This command will download the Jar specified and all its 
dependencies and load it into the classpath.
_Syntax:_
{code}
REGISTER <ivy://group:module:version?querystring>
{code}
Where,
* *group:* Which module group the module comes from. Translates directly to a 
Maven groupId or an Ivy Organization.
* *module:* The name of the module to load. Translated directly to a Maven 
artifactId or an Ivy artifact.
* *version:* The version of the module to use. You can specify a specific 
version or indicate * (latest version) or an Ivy Range '[2.2.1,)' meaning 2.2.1 
or any greater version.
* *queryString:* This will contain '&' separated key-value pairs to help us 
exclude all or specific dependencies etc.

_Example:_
{code}REGISTER ivy://org.apache.avro:avro:* {code}
h5.Parameters supported in query string:
# *Transitive*
Registering only the artifact without dependencies:  To download only the 
artifact we need to set transitive to false and pass it the query string. This 
will download only the artifact specified and will not download the 
dependencies of the jar. The default value of transitive is true.
_Syntax:_ 
{code}REGISTER <ivy://org:module:version?transitive=false>{code}
# *Exclude*
Registering Artifact by excluding some specific dependencies: If you want to 
download an artifact and its dependencies but want to exclude some specific 
dependencies from getting downloaded you can do so by specifying a comma 
separated list of dependencies.
_Syntax:_ 
{code}REGISTER <ivy://org:module:version?exclude=org:mod,org:mod,...>{code}
_Example:_
{code}REGISTER 
ivy://org.apache.pig:pig:0.10.0?exclude=commons-cli:commons-cli,commons-codec:commons-codec{code}
# *Classifier*
Some maven dependencies need classifiers in order to be able to resolve.
_Syntax:_ 
{code}REGISTER <ivy://org:module:version?classifier=value>{code}
_Example:_
{code}REGISTER ivy://net.sf.json-lib:json-lib:2.4?classifier=jdk15 {code}

*A few more points:*
# An optional property, 'ARTIFACT_DOWNLOAD_LOCATION' can set set to specify the 
location where the artifacts and dependencies should be downloaded. By default 
it will be downloaded to '~/.groovy/grapes/'
# All these register commands described above will also be supported in Macros.
# The repositories can be configured using the ivysettings file.

> Pig's register command should support automatic fetching of jars from repo.
> ---------------------------------------------------------------------------
>
>                 Key: PIG-4417
>                 URL: https://issues.apache.org/jira/browse/PIG-4417
>             Project: Pig
>          Issue Type: Improvement
>            Reporter: Akshay Rai
>
> Currently Pig's register command takes a local path to a dependency jar . 
> This clutters the local file-system as users may forget to remove this jar 
> later.
> It would be nice if Pig supported a Gradle like notation to download the jar 
> from a repository.
> Ex: At the top of the Pig script a user could add
> register '<group>:<module>:<version>'; 
> It should be backward compatible and should support a local file path if so 
> desired.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to