In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you how to use Jitpack to release open source Java libraries, detailed content, clear logic, I believe most people are too aware of this knowledge, so share this article for your reference, I hope you can learn something after reading this article, let's take a look at it.
Gradle
Gradle mainly talks about Android projects. If an ordinary Java project uses gradle for dependency management, then the process is the same, just follow the steps.
Release process 1. Create module
First, create a module and implement your own related code in it.
Enter the module name and package name you want, and keep the two ellipses in the module name (just change the following name)
Here I create a module of update as an example, as shown in the following figure:
Then you can write your own code in it (of course, here is an Android project, where you can write code such as Android pages, etc.), as usual
2.Gradle plug-in Settings
By default, you have finished your own development work. In order to demonstrate, I simply write a test class here, which is used to pop up the window.
First, add the following code (which is actually a packaging plug-in) to the root gradle setting of the project:
Classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
Add the following code to the gradle file in module:
Id 'com.github.dcendents.android-maven'// here is my own github account, which needs to be changed to your own group =' com.github.stars-one'
3. Project upload github
There is no more to say here. By default, everyone knows how to use github.
4.github creates relase version
5. Release open source library
Visit jitpack's official website https://jitpack.io/, enter the name of our open source library, find our open source library, and select get it to release the version.
For the released version, you need to wait for a period of time (up to 15 minutes), compile by the Jitpack server, and then see the status.
6. Use
Then add warehouse sources and dependencies to the gradle file and you can use it. You can add this referencing technique to the project's readme.md file a little bit, and you're done!
About Multi-module moudle
The above demonstration only tries the situation where there is a single module in a project, but sometimes we may have several module in a project. One of these module is necessary, while the other is optional. What should you do at this time?
The answer is very simple, and the above operation is the same.
But then, after the Jitpack release is successful, you have to manually check the log log to determine the version number.
Check the log and turn directly to the end, you can see the module
You don't have to say any more about the quote after that.
Implementation 'com.github.stars-one.android-component-libray:update:0.2'implementation' com.github.stars-one.android-component-libray:webviewBase:0.2'
PS: note here that when you have multiple module, don't assume that the previous approach introduces all dependencies at once, as shown below
/ / with such a dependency, no errors will be reported in the project, but the implementation 'com.github.stars-one.android-component-libray:0.2'maven of a specific class (that is, invalid references) cannot be used.
The above mainly explains the Gradle project, and then complements the Maven project.
Compared with Gradle, Maven is relatively simple, as long as you create a new maven project, upload it to github, and publish it according to the above operations.
However, in order to make it easy to use, we need to configure only pom.xml, which is mainly set so that you can see the comments and source code
The pom.xml configuration is as follows: you can configure the following plug-ins.
Org.apache.maven.plugins maven-compiler-plugin 3.2 1.7 1.7 org.apache.maven.plugins maven-source-plugin attach-sources Jar maven-javadoc-plugin attach-javadocs jar
It should be noted that when publishing using Jitpack, the package name is com.github.stars-one, and the package name and version number defined in pom.xml will not be used, as shown in the following two screenshots:
About Multi-module module
In the case of multiple modules, it is actually somewhat similar to a single module, so there is not too much expansion here.
However, in the official example, it is clear that all dependencies can be imported directly.
These are all the contents of the article "how to use Jitpack to publish open source Java libraries". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.