I want to build a jar file from OkHttp library source code to use a snapshot version in my android app. I can not figure out how.
Any help is welcome. Thanks.
git clone https://github.com/square/okhttp
cd okhttp
./gradlew jar
mkdir /tmp/okhttplibs
find . -name '*.jar' | xargs -I % cp % /tmp/okhttplibs
Related
I'm aware of artifactory (which is planned in the future), but it's requested to package the artifacts on our releases.
We currently do on a script:
printf "\nCopying artifacts...\n"
for artifact_dir in "$HOME"/.m2/repository/com/foo/{*-ear,*-ui,*-tool}; do
highest_version=$(find "${artifact_dir}"/* -maxdepth 1 -type d -printf "%f\n" | sort -V | tail -1)
artifact_name=$(basename "${artifact_dir}")
mkdir --parent "${artifacts_out}/com/foo/${artifact_name}/${highest_version}"
cp --archive "${artifact_dir}/${highest_version}"/* \
"${artifacts_out}/com/foo/${artifact_name}/${highest_version}"
done
But as you can see it's not very neat, p.e we can not create a release with older artifacts because the script always takes the newest one.
Is there a maven plugin or something that permits to archive specific artifacts ?
If you want to create bundles of artifacts, run the Maven assembly plugin during the build. It can be used to gather artifacts, zip them and deploy the result to Artifactory/Nexus.
I downloaded and built parquet-1.5.0 of https://github.com/apache/parquet-mr.
I now want to run some commands on my parquet files that are in hdfs. I tried this:
cd ~/parquet-mr/parquet-tools/src/main/scripts
./parquet-tools meta hdfs://localhost/my_parquet_file.parquet
and I got:
Error: Could not find or load main class parquet.tools.Main
Download jar
Download the jar from maven repo, or any location of your choice. Just google it. The time of this post I can get the parquet-tools from here.
If you’re logged in the hadoop box:
wget http://central.maven.org/maven2/org/apache/parquet/parquet-tools/1.9.0/parquet-tools-1.9.0.jar
This link might stop working few days later. So get the new link from maven repo.
Build jar
If you are unable to download the jar, you could also build the jar from source. Clone the parquet-mr repo and build the jar from the source
git clone https://github.com/apache/parquet-mr
mvn clean package
Note: you need maven on your box to build the source.
Read parquet file
You can use these commands to view the contents of the parquet file-
Check schema for s3/hdfs file:
hadoop jar parquet-tools-1.9.0.jar schema s3://path/to/file.snappy.parquet
hadoop jar parquet-tools-1.9.0.jar schema hdfs://path/to/file.snappy.parquet
Head file contents:
hadoop jar parquet-tools-1.9.0.jar head -n5 s3://path/to/file.snappy.parquet
Check contents of local file:
java -jar parquet-tools-1.9.0.jar head -n5 /tmp/path/to/file.snappy.parquet
java -jar parquet-tools-1.9.0.jar schema /tmp/path/to/file.snappy.parquet
More commands:
hadoop jar parquet-tools-1.9.0.jar –help
The script is built on the assumption that parquet-tools-<version>.jar is located in a directory called lib next to the script file itself, like so:
$ find -type f
./parquet-tools
./lib/parquet-tools-1.10.1-SNAPSHOT.jar
You can set up such a file layout by issuing the following commands from the root of the parquet-mr git repo (of course many alternative ways and installation locations are possible):
mkdir -p ~/.local/share/parquet-tools/lib
cp parquet-tools/src/main/scripts/parquet-tools ~/.local/share/parquet-tools/
cp parquet-tools/target/parquet-tools-1.5.0.jar ~/.local/share/parquet-tools/lib
After this you can run ~/.local/share/parquet-tools/parquet-tools. (I tested this with version 1.10.1-SNAPSHOT though instead of 1.5.0.)
I have an Eclipse setup with m2eclipse and subversive. I have imported a maven2 project from svn. But I get the error message that a whole bunch of artifacts are missing (for instance: Missing artifact org.springframework:spring-test:jar:3.0.1.RELEASE:test).
If I look in my repository I see the jar files there but they have an extra extension .lastUpdated. Why is maven appending .lastUpdated to the jars? And more importantly: how can I fix this?
There is no mention of the type lastUpdated in my POMs.
These files indicate to Maven that it attempted to obtain the archive by download, but was unsuccessful. In order to save bandwidth it will not attempt this again until a certain time period encoded in the file has elapsed. The command line switch -U force maven to perform the update before the retry period. This may be necessary if you attempted to build while disconnected from the network.
The method of removing the files works with most versions of maven, but since the files are internal mementos to maven, I would not recommend this method. There is no guarantee that this information is not referenced or held elsewhere and such manipulation can damage the system.
As rperez said, I use to delete all those .lastUpdated files. In Linux I have created a little script to keep it simple:
find -name \*.lastUpdated -exec rm -fv {} +
Just create a file with the previous content and put it on your local Maven repository. Usually it will be ~/.m2/repository.
I installed Maven2 and ran mvn compile from the command line. This seems to have resolved the problem
you might have a problem with some of the artifacts to be retrieved from the repository. for example spring framework has its own repository. this xtension is appended when the artifact cannot fully downloaded. add the spring framework repository to your pom or settings.xml, delete the folder that include the broken jars and start again
If you hit this problem and you're using Nexus, it might be the case that you have a routing rule defined, which is incorrect. I hit this myself and the files it was downloading were correctly named, at the proper URL-s it was looking at, but they were all with the .lastUpdated extension and an error message as contents.
Open your terminal, navigate to your Eclipse's project directory and run:
mvn install
If mvn install doesn't update your dependencies, then call it with a switch to force update:
mvn install -U
This is a much safer approach compared to tampering with maven files as you delete ".lastUpdated".
Use this command inside the .m2/repository dir to rename all files:
for file in `find . -iname *.lastUpdated`; do renamed=$(echo $file | rev | cut -c13- | rev); echo renaming: $file to $renamed; mv $file $renamed; done
This is usefull to not download all sources again.
This not work... The .jar is lost. :(
What I do when I encounter this issue:
Make sure you have the version of the latest 'maven-source-plugin' plugin:
https://maven.apache.org/plugins/maven-source-plugin/usage.html
$ mvn source:jar install
Now if the file *.lastUpdate exist in your local ~/.m2/repositories/your-lib/0.0.1/ directory you can just remove it then run the command above again.
This is a side-effect of a failure to successfully extract from the repository. To get the actual content you want into your repository, check for correct paths to the repository/repositories within your pom file, and resolve certificate/security issues, if any. It is almost invariably one or the other of these issues.
There is no need to delete the .lastUpdated entries, and doing so won't solve your problem.
In our project, Maven build generates artifacts for different modules i.e. jar, console, car etc in corresponding folder structure.
Everytime we check in the code, the build genarates full new artifacts even if there is only change in "console" module.
Is there any Maven plugin or a way to generate only the artifacts which were changed since last successful build?
For instance, if I have changed the code for "console" module, then the artifact generated should only have console file in its corresponding folder.
If you are on command line you can use
mvn -pl moduleToBuild
which can be combined with:
mvn -pl moduleToBuild -am
which will also build the dependencies of moduleToBuild.
If you are in a CI solution like jenkins there is a check box to activate this behaviour. This can be found under the Maven configuration part Incremental build - only build changed modules.
You have to start the maven call on the root of your multi-module build.
You may want to look at using maven reactor plugin's reactor:make-scm-changes goal. This link has example on how to use this.
I was looking for something that would check what files I have changed compared to the "upstream" version, and build all Maven modules which contain the files, and all depending on them.
Since reactor:make-scm-changes doesn't seem to do that, one way to do it (Linux Bash way) is to
list the changed files, using (git diff --name-only master...),
find the nearest pom.xml for all,
deduplicate (... | sort | uniq),
provide it to Maven as a list using --project-list, with --also-make.
The rest is joining it together using pipes and functions.
Of course this assumes that all sources are within the folder with pom.xml, which typically is true.
Here's an example of the approach mentioned by Ondra Žižka, using mvn clean install and bash.
Note, it ignores pom packaging modules (as those are typically roots of subtrees and would usually cause additional, unnecessary modules to be built. It also looks for pom.xml files 3 levels deep (for speed), assuming they're all part of the same reactor, but this can be adjusted to your project.
find . -maxdepth 3 -name pom.xml | xargs -I{} grep -iL -F "<packaging>pom</packaging>" {} | xargs dirname | grep -v target | sed -e 's/^.[/]*//g' | grep . > /tmp/mvn-modules.txt && git diff --name-only #{u}...HEAD | grep -o -F -f /tmp/mvn-modules.txt | xargs | tr ' ' ',' | xargs -I{} mvn clean install -U -pl {} -amd
In the example #{u}...HEAD references changes in current branch compared to upstream, but this can be swapped for another diff (example <branchname> master) if this is more suitable.
Actually, I want to integrate spring javadoc with my netbeans IDE. Spring website only provides an HTML version javadoc online, no download link. But Netbeans only accept a jar/zip file or a local folder.
I know I can build it myself from spring source, but would rather not go through the work.
You can download from this location http://repo.spring.io/libs-release/org/springframework/spring/
You need the -with-docs.zip download
http://www.springsource.com/download/community
It seems the downloads are now managed with Maven only, however, if you want a copy of the JavaDocs locally you could use wget on the JavaDoc URL.
e.g. For release 3.0.5.RELEASE this works a treat.
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains docs.spring.io \
--no-parent \
http://docs.spring.io/spring/docs/3.0.5.RELEASE/javadoc-api/
Or you can just grab the version with source code (which is even better in your IDE anyway).
Sign up over at http://www.springsource.com or just grab it from a maven repository like this one:
http://www.jarvana.com/jarvana/browse/org/springframework/spring-jdbc/
Just grab the release you want (like 2.5.6/spring-jdbc-2.5.6-sources.jar), save to disk, and in Netbeans right-click on your library and select "add local sources".
/ Papa Freud
Using of Maven works for me. In the directory with pom.xml type the command:
mvn dependency:sources -DincludeArtifactIds=spring-aop -Dclassifier=javadoc
After that the jar is available in the ~/.m2 directory.
Now Spring uses artifactory.
Go to corresponding folder for further download.
http://repo.spring.io/webapp/browserepo.html?24