Skip to content

Update of the project #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 1 addition & 28 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: Release PokeAPI

env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

on:
push:
tags:
Expand Down Expand Up @@ -48,7 +44,7 @@ jobs:

- name: Build .jar
run: sh gradlew build

- name: Create Release
if: ${{ success() }}
id: create_release
Expand All @@ -60,26 +56,3 @@ jobs:
body: ${{steps.build_changelog.outputs.changelog}}
artifacts: "${{ github.workspace }}/build/libs/pokeapi-${{ env.PROJECT_VERSION }}.jar"
makeLatest: "latest"

publish:
name: Publish PokeAPI
runs-on: ubuntu-latest
needs:
- release

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Publish PokeAPI
run: sh gradlew build

- name: Publish PokeAPI
if: ${{ success() }}
run: sh gradlew publish
31 changes: 31 additions & 0 deletions .github/workflows/publish_maven_central.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name : Publish PokeAPI

env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

on:
release:
types: [created]

jobs:
publish:
name: Publish PokeAPI
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Publish PokeAPI
run: sh gradlew build

- name: Publish PokeAPI
if: ${{ success() }}
run: sh gradlew publish
9 changes: 8 additions & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 62 additions & 37 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

val artifact = "pokeapi"
val projectName = "PokeApi"
val projectDocUrl = "https://tykok.github.io/PokeAPI-Kotlin/"
val sonarSnapshotUri = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
val sonarReleaseUri = "https://s01.oss.sonatype.org/content/repositories/releases/"
val projectUrl = "https://github.com/Tykok/PokeAPI-Kotlin"
val mavenCentralPublishURI = uri("https://central.sonatype.com/api/v1/publisher/deployments/download/")

description = "PokeApi is a simple library you can use to make request to get data about Pokémon."
group = "fr.tykok"
version = "1.0.0"

fun getUriSonar(): String = if (version.toString().endsWith("SNAPSHOT")) {
sonarSnapshotUri
} else {
sonarReleaseUri
}

plugins {
alias(libs.plugins.netResearchgateRelease)
alias(libs.plugins.dokka)
alias(libs.plugins.ktlint)
`java-library`
`maven-publish`
signing
java
kotlin("jvm") version "1.7.10"
kotlin("jvm") version "2.0.0"
application
signing
id("net.researchgate.release") version "3.0.2"
id("org.jetbrains.dokka") version "1.9.0"
id("org.jlleitschuh.gradle.ktlint") version "11.6.0"
jacoco
}

repositories {
Expand All @@ -42,26 +37,43 @@ java {

dependencies {
testImplementation(kotlin("test"))
implementation("com.squareup.okhttp3:okhttp:4.10.0")
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
implementation("com.fasterxml.jackson.core:jackson-databind:2.0.1")
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation("com.google.code.gson:gson:2.10.1")
implementation(libs.okhttp)
implementation(libs.jackson)
implementation(libs.gson)

testImplementation(platform(libs.junitBom))
testImplementation(libs.junitJupiter)
testRuntimeOnly(libs.junitPlatform)
testImplementation(libs.mockk)
}

tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
tasks.test {
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
}
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
}

kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_17)
}
}

tasks.create("getProjectVersion") {
doLast {
logger.quiet("VERSION: $version")
}
}

tasks.register<Jar>("dokkaHtmlJar") {
dependsOn(tasks.dokkaHtml)
from(tasks.dokkaHtml.flatMap { it.outputDirectory })
Expand All @@ -87,7 +99,15 @@ task<Exec>("mkdocs-build") {
}

application {
mainClass.set("PokeApi")
mainClass.set("fr.tykok.pokeapi.PokeApi")
}

sourceSets {
test {
kotlin {
srcDir("src/test/kotlin")
}
}
}

signing {
Expand All @@ -96,35 +116,40 @@ signing {

publishing {
publications {
create<MavenPublication>("library") {
from(components["java"])
}
create<MavenPublication>("mavenJava") {
from(components["kotlin"])

groupId = groupId
artifactId = artifactId
version = version

pom {
name.set(projectName)
description.set(description)
url.set(projectDocUrl)
url.set(projectUrl)

licenses {
license {
name.set("MIT License")
url.set("https://github.com/Tykok/PokeAPI-Kotlin/blob/main/LICENSE")
}
}

developers {
developer {
name.set("Tykok")
}
}
}
}
}

repositories {
maven {
url = uri(getUriSonar())
name = projectName
group = group
version = version.toString()
description = description
name = "sonatype"
url = mavenCentralPublishURI

credentials {
username = project.findProperty("ossrh.username") as String?
?: System.getenv("OSSRH_USERNAME")
password = project.findProperty("ossrh.password") as String?
?: System.getenv("OSSRH_PASSWORD")
username = project.findProperty("ossrhUsername") as String? ?: System.getenv("OSSRH_USERNAME")
password = project.findProperty("ossrhPassword") as String? ?: System.getenv("OSSRH_PASSWORD")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/mkdocs-markdown/entities/berry.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Berry

The `Berry` entity is used to map data from `https://pokeapi.co/api/v2/berry/...`.
The `Berry` entities is used to map data from `https://pokeapi.co/api/v2/berry/...`.

![Berry](../img/berry.jpeg)

Expand Down
8 changes: 4 additions & 4 deletions docs/mkdocs-markdown/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
To use the methods, you need to import `PokeApi` class. Next, you can use the `get` methods to fetch data from the
[pokeapi.co][pokeapi].

You need to give the entity type as a generic parameter to the `get()` methods. The available entity types are available
in the `fr.tykok.pokeapi.entity` package, all the documentation are given in the `API Resource` section of this website.
You need to give the entities type as a generic parameter to the `get()` methods. The available entities types are available
in the `fr.tykok.pokeapi.entities` package, all the documentation are given in the `API Resource` section of this website.

All entities used to call a specific endpoint and is used to map the response of the endpoint.
Each entity are described in the entities section.
Each entities are described in the entities section.

Finally, you need to give an `id`, the `name`, or the `limit` of the list to get the entity or the list of entities
Finally, you need to give an `id`, the `name`, or the `limit` of the list to get the entities or the list of entities
given in the generic parameter.
All parameters for the `get()` method are described below.

Expand Down
28 changes: 14 additions & 14 deletions docs/site/entities/berry/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
<link rel="stylesheet" href="../../css/theme.css" />
<link rel="stylesheet" href="../../css/theme_extra.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/github.min.css" />

<script>
// Current page data
var mkdocs_page_name = "Berry";
var mkdocs_page_input_path = "entities/berry.md";
var mkdocs_page_url = "/PokeAPI-Kotlin/entities/berry/";
</script>

<script src="../../js/jquery-3.6.0.min.js" defer></script>
<!--[if lt IE 9]>
<script src="../../js/html5shiv.min.js"></script>
<![endif]-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script>hljs.initHighlightingOnLoad();</script>
</head>

<body class="wy-body-for-nav" role="document">
Expand Down Expand Up @@ -95,7 +95,7 @@
<nav class="wy-nav-top" role="navigation" aria-label="Mobile navigation menu">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../..">PokeApi - Documentation</a>

</nav>
<div class="wy-nav-content">
<div class="rst-content"><div role="navigation" aria-label="breadcrumbs navigation">
Expand All @@ -111,11 +111,11 @@
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div class="section" itemprop="articleBody">

<h1 id="berry">Berry</h1>
<p>The <code>Berry</code> entity is used to map data from <code>https://pokeapi.co/api/v2/berry/...</code>.</p>
<p>The <code>Berry</code> entities is used to map data from <code>https://pokeapi.co/api/v2/berry/...</code>.</p>
<p><img alt="Berry" src="../../img/berry.jpeg" /></p>

</div>
</div><footer>
<div class="rst-footer-buttons" role="navigation" aria-label="Footer Navigation">
Expand All @@ -131,7 +131,7 @@ <h1 id="berry">Berry</h1>

Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>

</div>
</div>

Expand All @@ -141,17 +141,17 @@ <h1 id="berry">Berry</h1>

<div class="rst-versions" role="note" aria-label="Versions">
<span class="rst-current-version" data-toggle="rst-current-version">

<span>
<a href="https://github.com/Tykok/PokeAPI-Kotlin" class="fa fa-github" style="color: #fcfcfc"> GitHub</a>
</span>


<span><a href="../pokemon/" style="color: #fcfcfc">&laquo; Previous</a></span>


<span><a href="../contest/" style="color: #fcfcfc">Next &raquo;</a></span>

</span>
</div>
<script>var base_url = '../..';</script>
Expand Down
Loading
Loading