Download Jar file from private GitHub repo in Java - java

I have 3 private GitHub repos, using Java, I would like to login to my account, and download a jar file from the RAW section of the repo. A simple task if the repos were public. But not so when private.
I have thought about using Apache2's HttpClient. However I have no clue (and googling didn't help either) how GitHub's auth is laid out.
I thought there might be some kind of library for GitHub in Java, but the only Lib I can find doesn't allow downloading of files (here). Only logging in to the GitHub auth and pushing commits/fetching repos, etc. Which isn't what I am looking to do.
Any help is greatly appreciated, thanks.
Since I can't create an answer.
Using the API here
You can create a download service and download the repo. I've not worked out how yet, but I'm pretty sure it's possible, and I will update this answer once I've done it. I need to grab the "IRepositoryIdProvider"

You can use Apache common's HttpClient library to give better control of the credentials/cookies/auth stuff to allow you to get the access. I think that is the problem, right?

Related

Adding Code Snippet to Resources - Gradle / Twitter API

I am using the Twitter API to learn about how APIs work, and I ran into a spot that confused me. The docs tell you to add a code snippet to your resources for the app. Do I add a file? If so, what type?
The code snippet above is supposed to go in my resources. What file should I add to do so?
I looked for solutions to this, but they troubleshoot very specific issues. I am looking for a general explanation of how to add resources.
The file is "application.properties" and does need to be added to the resources folder.

Import Neo4J API in Netbeans

For a project I am building a Java GUI from which queries can be sent to Neo4j, to make it easier to do particular analyses. To get this all working, I have downloaded a .jar folder containing all relevant classes (neo4j-javadocs-2.1.7-javadoc.jar). I have loaded the library through the project->properties->libraries->Add JAR, but I can't seem to import the classes I want to use in my GUI (neither automatically nor manually).
I am dabbling in Java, so it is probably a basic oversight that I am making, but with the help from tutorials online and trying different commands (like entering the path of the .jar file) I can't get it working. One of these tutorials is specific on the Neo4j library, so I am very confused. That tutorial is written for Eclipse, instead of NetBeans which I am working with, but as far as my knowledge goes that shouldn't matter for the commands
I don't have enough reputation to post direct images, but this link contains a screenshot. If more information is required, let me know. http://i.stack.imgur.com/lUytK.png
Additionally, when I normally add a class that is not imported, there is an automatic function to import the class. This option is missing for my specific class, so maybe I added the library in an incorrect way?
http://i.stack.imgur.com/QeDX4.png
Edit: Issue resolved thanks to a colleague that came in. Apparently I loaded the Javadoc where I should have loaded to individual classes from the lib directory.
It really should work.
Try to save all changes. NetBeans reparses the classes when you save them.
Try to build your project manually from command line using Ant build script
Use Maven, Ivy or Gradle for Dependency Management then you can depend on the Neo4j artifacts.
For sending queries to the server you actually don't need Neo4j artifacts.
You can also use the JDBC driver, see http://neo4j.com/developer/java

Openfire libs download

I have downloaded openfire source code, And as mentioned in tutorial it requires coherence.jar, coherence-work.jar, tangosol.jar.
I google'd it but not found any direct downloading link for these jars.
From where I can download these jars. Any link ?
Help appreciated.
You don't need them at all. These were required if you wanted to cluster Openfire, but the that has since been replaced by a Hazelcast based solution.
Unless you are setting up a cluster, neither is necessary.

Any website with a list of thirdparty java libraries?

I'm wondering if there is a website with like a list of java libraries/jars where you can browse around and see if theres something you could use. like when you make your own program which then contains lots of useful stuff.
Sort of like a website where people share their code, for public use.
SourceForge
Freecode (Freshmeat)
Google Code
github
Java.net
http://mvnrepository.com - if you know jar name or package name. it will provide you available versions and pom/ivy/gradle coordinates for copy/paste.
http://findjar.com/ - helps you to find jar containing this f*%^ing class nobody knows about (and then you can search mvnrepository to look if it is available for maven build - if not, the best is just ignore this library as this is probably of low quality or not yet released to public properly)

Is it possible to host an Eclipse update site on Github?

I am using GitHub to develop an Eclipse plugin. I would like to have a public Eclipse update site for my plugin. Can I use GitHub for this?
I know that GitHub can be used for hosting individual files by using the "raw" links provided on the file information pages.
Forget the Github project releases feature, that won't work as a true update site (see notes at the end).
To achieve what you want, you can create a Github repo, commit/push your p2 repository there and then serve it as an update site, using raw links.
So for example, for the repository:
https://github.com/some-user/some-repository/
you can serve it as an update site using the link:
https://github.com/some-user/some-repository/raw/master/
Notes: Yes, if you open the update site link in a browser, github will give you no file listings, but rather a 404. But that's fine. The Eclipse update site mechanism doesn't need the parent link to be valid. Instead Eclipse will directly look for <update-site URL>/artifacts.jar (or .xml) and from the information in artifacts.jar, it will itself discover the URLs of the other artifacts stored in the update site. AFAIK, at no point does the Eclipse update mechanism need the web server to do file listings of a directory.
Note2: if you use Github project releases, you can only attach a zipped p2 repository to it. That is not a proper update site because it is a static repository: there is no URL to which new releases can be uploaded to. Eclipse won't be able to automatically discover new updates, rather the user will need to download the zip for each new release he/she wants to update to.
(Also with a proper update site, only the necessary artifacts for installation/update/query will be downloaded - a minor advantage)
Github pages are not a proper place for an update site.
Github pages may not properly serve large binary files as explained in this issue. It may be fine if your jars are small but overall they advise against placing binaries there. Instead they recommend placing binaries in the download section of the repository. I'd be happy if this situation changes because it would be very convenient to publish an update site by pushing to github.
For now one would have to use their API to programatically upload files in the download section. Answers to this other question points to some libraries and scripts that uses this API for use within java/maven, perl, ruby, etc.
You may now try it in a release page (July 2013).
See "Publish a project release (binary/source packages) on Github?"
Original answer (January 2013)
I have not tested it, but technically, a p2 repository can be defined in any shared path (either filesystem-shared or web-based-shared)
You should only need to:
generate the right p2 metadata
analyze the p2 repo in case of any issue.
store the all result in a git managed directory and push it to your GitHub repo.
http://pages.github.com/
The Github Pages feature allows you to host arbitrary folders of files without git turning each file into a github page.
I was able to host an Eclipse update site using the GitHub pages feature. I found it difficult to figure out all the pieces I needed, so here's a brief description of the steps I followed.
Build your Eclipse plug-in project, and test it on your local workstation.
Add a feature project, and add your plug in. Also set the description, copyright, and license information.
Configure a publishing source for your repository. I think the /docs folder is the easiest to work with. One way to generate a starting web site is to go to the GitHub repository settings page, and launch the automatic page generator.
Create an update site project nested inside the /docs folder. Put it in an obvious folder, like update.
Create a category, and add the feature to the update project.
Click the Build all button to generate the jar files.
Commit and push all the changes.
Try installing from the update site.
Once the update site works, you can publish your plug in in the Eclipse marketplace. This is optional, it just makes your plug in easier to find.
As others have mentioned, GitHub pages don't support huge binary files, so this will only work for small projects. To see an example, look at my Live Coding in Python project.
No it is not possible anymore, the Downloads API has officially been deprecated.
From the GitHub blog:
However, some projects need to host and distribute large binary files in addition to source archives. If this applies to you, we recommend using one of the many fantastic services that exist exactly for this purpose such as Amazon S3 / Amazon CloudFront or SourceForge. Check out our help article on distributing large binaries.
See this help article on distributing large binaries.
It turns out you absolutely can use GitHub Releases to host a p2 update site.
The main issue is that GitHub Releases hosts all files under a flat directory structure. Eclipse p2 repositories however, are hierarchical by default.
Since Eclipse Tycho (p2 actually), doesn’t allow you to configure a flat p2 repo structure, you need to script it.
The script needs to perform 2 things:
move every file under plugins/ and features/ to the root of the p2 repository,
replace all references to /plugins/ and /features/ with /, in the artifacts.xml file compressed in artifacts.jar and artifacts.xml.xz.
There are probably several ways to do it but in this blog post, you can see an implementation relying on a JBang script to achieve the desired goal:
https://fbricon.github.io/posts/use-github-releases-as-p2-repo/

Categories