A library to check artifact versions programmatically (currently with MavenCentral repository)
dependencies {
implementation "com.github.icarohs7:depchecker-core:$depchecker_version"
}
repositories {
maven { url "https://jitpack.io" }
}
The core functionality of this library is checking versions of artifacts, as below:
val artifact = Artifact("com.github.icarohs7.unoxlib:UNoxLib")
// OR
val artifact = Artifact(group = "com.github.icarohs7.unoxlib", artifactId = "UNoxLib")
// Returns a string with the last version of the artifact
assertThat(MavenCentralRepositoryImpl.getLastVersion(artifact), `is`("0.3.1"))
// Returns a list of versions of an artifact
val expectedVersionList = listOf(
"0.3.1",
"0.3.0",
"0.2.4",
"0.2.3",
"0.2.0",
"0.1.1"
)
assertThat(MavenCentralRepositoryImpl.getAllVersions(artifact), `is`(expectedVersionList))
Both functions can also be called as instance members of the class Artifact with the names
getLastVersionAt(DcRepository): String?
and getAllVersionsAt(DcRepository): List<String>
It also exposes a interface to be implemented to save collections of artifacts to the storage of your preference, coming with a buit-in in-memory implementation.
//Get an instance of the DAO used to store your saved artifacts
//getInMemoryDatabaseInstance() - Built-in implementation using RAM as storage
val artifactDao = ArtifactDao.getInMemoryDatabaseInstance()
val artifact = Artifact("com.github.icarohs7:depchecker-core")
- Persisting an artifact
artifactDao.insert(artifact)
- Reading the list of persisted artifacts
val allArtifacts = artifactDao.queryAll()
assertThat(allArtifacts, `is`(listOf(artifact)))
- Removing an artifact from the storage
artifactDao.remove(artifact)
- Clearing the storage
artifactDao.removeAll()
It is possible to easily add more repositories by simply creating
a class implementing the interface DcRepository
and its methods,
as shown in the class MavenCentralRepositoryImpl
, under
the package repositories, you can also implement your storage method
through the interface ArtifactDao
More usages can be found under the test package