How can i create an artifact and use it in other project?

I have a multi-project build. In projectA there is a first-jar1.jar that is created, i will use this jar as an artifact in projectB.
In projectB I have a dependency to projectA, i created a java class in which i use object from first-jar1.jar , but it doesn’t seem to recognize this objetcs because it is not able to find the projectA artifact (first-jar1.jar).
also in my build, i have a compilation error.

However this type of dependency on the other project doesn’t appear to locate the artifact first-jar1.jar.
Is there a way to make projectB aware of the artifact from projectA, without pushing artifacts to an external repository?

ProjectA/build.gradle :
plugins {
id ‘java-library’
id ‘java’
}
repositories {
jcenter()
}

dependencies {
api ‘org.apache.commons:commons-math3:3.6.1’
implementation ‘com.google.guava:guava:26.0-jre’
testImplementation ‘junit:junit:4.12’
compile group: ‘org.apache.commons’, name: ‘commons-lang3’, version: ‘3.0’
}
sourceSets {
SourceSetA{
java {
srcDirs ‘src/main/java/PackageA’
}
}
}
task jarA(type:Jar){
from(sourceSets.SourceSetA.output) {
archivesBaseName = ‘first’
}
classifier = ‘jar1’
}
artifacts{
archives jarA
}

Project B / build.gradle

plugins {
id ‘java-library’
}
repositories {
jcenter()
}
dependencies {
api ‘org.apache.commons:commons-math3:3.6.1’
implementation ‘com.google.guava:guava:26.0-jre’
testImplementation ‘junit:junit:4.12’
compile ‘ch.qos.logback:logback-classic:1.1.2’
compile ‘junit:junit:4.12’
compile project(’:ProjectA’)

sourceSets {
SourceSetB{
java{
srcDirs ‘src/main/java/PackageB’
}
}
}

task jarB(type:Jar , dependsOn:‘jarA’){
from(sourceSets.SourceSetB.output) {
archivesBaseName = ‘second’
}
classifier = ‘jar2’
}

Setting.gradle : ProjectB

rootProject.name = ‘ProjectB’
include “:ProjectA”
project(":ProjectA")