Uploading Android native artifacts to Maven - android-studio

I pushed a build artifact up to GitLab. I can see that it is there via the GitLab UI. Access to it is public, I checked by downloading using the mvn command line.
publishing {
publications {
release(MavenPublication) {
group = 'com.lowpan.m2'
artifactId = 'CHIPController'
version = '1.0.0'
artifact("third_party/connectedhomeip/libs/CHIPController.jar")
}
}
repositories {
maven {
url "https://gitlab.com/api/v4/projects/43346074/packages/maven"
name "GitLab"
credentials(HttpHeaderCredentials) {
name = 'Private-Token'
value = gitLabPrivateToken
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
Public registry link https://gitlab.com/lowpan/maven/-/packages
So as a test I tried downloading it
repositories {
google()
mavenCentral()
maven {
name = 'GitLab'
url = 'https://gitlab.com/api/v4/projects/43346074/packages/maven'
}
}
dependencies {
// Native libs
implementation 'com.lowpan.m2:CHIPController:1.0.0'
Gradle can't find it. From the debug log gradle does not even appear to be checking my repository.
Resolve mutations for :app:extractIncludeDebugProto (Thread[Execution worker,5,main]) started.
Resolve mutations for :app:extractIncludeDebugProto (Thread[Execution worker,5,main]) completed. Took 0.0 secs.
:app:extractIncludeDebugProto (Thread[Execution worker,5,main]) started.
> Task :app:extractIncludeDebugProto FAILED
Resource missing. [HTTP GET: https://dl.google.com/dl/android/maven2/com/lowpan/m2/CHIPController/1.0.0/CHIPController-1.0.0.pom]
Resource missing. [HTTP GET: https://repo.maven.apache.org/maven2/com/lowpan/m2/CHIPController/1.0.0/CHIPController-1.0.0.pom]
Registered task dependencies: app:debugCompileClasspath
Skipping misunderstood TO dep string: com.google.firebase:firebase-crashlytics-ktx
Skipping misunderstood TO dep string: com.google.firebase:firebase-analytics-ktx
Skipping misunderstood TO dep string: com.google.firebase:firebase-auth-ktx
Skipping misunderstood TO dep string: com.google.firebase:firebase-firestore-ktx
Skipping misunderstood TO dep string: com.google.firebase:firebase-perf-ktx
Skipping misunderstood TO dep string: com.google.firebase:firebase-config-ktx
Starting dependency analysis
:app:extractIncludeDebugProto (Thread[Execution worker,5,main]) completed. Took 0.269 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:extractIncludeDebugProto'.
> Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find com.lowpan.m2:CHIPController:1.0.0.
Required by:
project :app
So a couple of questions...
Why can't it find the file?
I am trying to package these files, https://github.com/google-home/sample-app-for-matter-android/tree/main/app/third_party/connectedhomeip
How can I put only these files into a maven object?
How do I tell gradle to unpack them into app/third_party/connectedhomeip/...?

Related

Could not download groovy-all.jar (org.codehaus.groovy:groovy-all:2.4.15) Azure DevOps Build pipeline run not executed and getting this error

- Execution failed for task ':app:lint'.
> Could not resolve all files for configuration ':app:lintClassPath'.
> Could not GET 'https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy-all/2.4.15/groovy-all-2.4.15.jar'.
> Connection reset
> Could not download kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.3.21)
> Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.3.21/kotlin-reflect-1.3.21.jar'.
> Could not HEAD 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.3.21/kotlin-reflect-1.3.21.jar'.
> Connection reset
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 9m 34s Error: The process 'D:\a\1\s\gradlew.bat'
failed with exit code 1
at ExecState._setResult (D:\a\_tasks\Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4\2.186.0\node_modules\azure-pipelines-task-lib\toolrunner.js:937:25)
at ExecState.CheckComplete (D:\a\_tasks\Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4\2.186.0\node_modules\azure-pipelines-task-lib\toolrunner.js:920:18)
at ChildProcess.<anonymous> (D:\a\_tasks\Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4\2.186.0\node_modules\azure-pipelines-task-lib\toolrunner.js:833:19)
at ChildProcess.emit (events.js:198:13)
at maybeClose (internal/child_process.js:982:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5) No test result files matching
D:\a\1\s\**\TEST-*.xml were found, so publishing JUnit test results
is being skipped.
##[error]Error: The process 'D:\a\1\s\gradlew.bat' failed with exit code 1 Finishing: gradlew build
Project Gradle
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "https://jitpack.io"
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// Check for v3.1.2 or higher
classpath 'com.google.gms:google-services:4.3.0'
// Add dependency
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
}
}
plugins {
id "org.sonarqube" version "2.7"
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
maven {
url "https://jitpack.io"
}
flatDir {
dirs 'src/main/libs'
}
configurations.all {
resolutionStrategy {
force "com.google.android.gms:play-services-basement:16.2.0"
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Azure DevOps Build pipeline run not executed and getting this error.
Anyway, build the project in Android Studio 4.2 (local machine) successfully without error.
I don't know what is causing it to stop downloading or not allowing it to download the groovy file but I am stuck here and can't release my app :(

Publish Jar into Azure Artifact using gradle error

What I'm trying to do is to publish a Jar file into the Azure DevOps artifact using Gradle but I got this error massage:
FAILURE: Build failed with an exception.
What went wrong:
Task 'publish' not found in root project 'Project1'.
Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
and the Build.gradle file is this:
apply plugin: 'java'
apply plugin: 'maven-publish'
publishing {
publications {
myPublication(MavenPublication) {
groupId 'soft'
artifactId 'crypto-utils'
version '5.2.0'
artifact 'C:\Users\d\Desktop\Project1\crypto-utils-5.2.0.jar'
}
}
// Repositories *to* which Gradle can publish artifacts
repositories {
maven {
url 'https://pkgs.dev.azure.com/soft/pm/_packaging/myFeed/maven/v1'
credentials {
username "myFeed"
//The Azure DevOps Services build system will use the "SYSTEM_ACCESSTOKEN" to authenticate to Azure DevOps Services feeds
password System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") != null ? System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") : vstsMavenAccessToken
}
}
}
}
// Repositories *from* which Gradle can download dependencies; it's the same as above in this example
repositories {
maven {
url 'https://pkgs.dev.azure.com/soft/pm/_packaging/myFeed/maven/v1'
credentials {
username "myFeed"
//The Azure DevOps Services build system will use the "SYSTEM_ACCESSTOKEN" to authenticate to Azure DevOps Services feeds
password System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") != null ? System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") : vstsMavenAccessToken
}
}
}
Any help please
The problem may be caused by using gradle in the wrong path. You need to run gradle in the same directory as the Build.gradle file.
If you are using Azure DevOps build pipeline, the root directory path of the repository is $(system.defaultworkingdirectory).
Other than that, you can try gradle clean build instead of gradle build.

runing an Azure DevOps pipeline for a Talend ESB project maven error

I'm trying to run an Azure DevOps pipeline for talend ESB project but I got this error message:
[ERROR] Failed to execute goal on project routines: Could not resolve dependencies for project org.example.local_project.code:routines:jar:7.3.1: Could not find artifact org.talend.libraries:crypto-utils:jar:5.2.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :routines
Any help please.
According to the error message log, this error generally occurs when Maven could not download dependencies. Possible causes for this error are:
The POM misses the declaration of the which hosts the
artifact.
The repository you have configured requires authentication and Maven
failed to provide the correct credentials to the server. In this
case, make sure your ${user.home}/.m2/settings.xml contains a
declaration whose matches the of the remote
repository to use. See the Maven Settings Reference for more
details.
The remote repository in question uses SSL and the JVM running Maven
does not trust the certificate of the server.
There is a general network problem that prevents Maven from
accessing any remote repository, e.g. a missing proxy configuration.
You have configured Maven to perform strict checksum validation and
the files to download got corrupted.
Maven failed to save the files to your local repository, see
LocalRepositoryNotAccessibleException for more details.
You can refer to this document to troubleshoot.

Jenkins build not failing at pipeline stage where OWASP Dependency Checker finds vulnerabilities

I am trying to fail my Jenkins build at the pipeline stage when OWASP Dependency checker finds and reports out vulnerabilities found. But instead it is moving forward and executing all the subsequent stages even if a vulnerability is found. My Jenkinsfile looks like this :-
pipeline {
tools {
nodejs "nodejs"
}
stages {
stage('install') {
steps {
// 'ci' install node modules
sh 'npm ci'
}
}
stage('Dependency Check') {
steps {
sh 'npm prune --production'
sh "mkdir -p build/report"
sh "'$DEPENDENCY_PATH' --project demoProject --disableRetireJS --suppression 'dependency-check-suppressions.xml' --format XML --out 'build/report/dependency-check-report.xml' --scan ."
dependencyCheckPublisher pattern: 'build/report/dependency-check-report.xml', failedTotalCritical: '0', failedTotalHigh: '0', failedTotalLow: '0', failedTotalMedium: '0'
}
}
stage('Test Step') {
steps {
sh 'echo "Reaching test step"'
}
}
}
}
Env. variable '$DEPENDENCY_PATH' contains the location for dependency-check.bat file. OWASP Dependency Checker finds and reports vulnerabilities which I can see in the dependency-check-report.xml and at the end it fails the build also. But the last stage Test Step also gets executed which I do not want. I want Jenkins build to fail at the Dependency Check stage if any vulnerabilities are found. Where am I doing wrong here?
Less hacky way that does not require whitelisting:
dependencyCheckPublisher (
pattern: '**/build/reports/dependencyCheck/dependency-check-report.xml',
failedTotalLow: 1,
failedTotalMedium: 1,
failedTotalHigh: 1,
failedTotalCritical: 1
)
if (currentBuild.result == 'UNSTABLE') {
unstable('UNSTABLE: Dependency check')
} else if (currentBuild.result == 'FAILURE') {
error('FAILED: Dependency check')
}
It seems that DependencyCheckPublisher throws an error but Jenkins is unable to catch it at that point, but at the end it checks for the same and fails the build. To catch the error at the exact point where it is thrown by DependencyCheckPublisher, I had to introduce a rawBuild console output check which checks whether DependencyCheckPublisher has printed anything about exceeded count for vulnerabilities or not. After dependencyCheckPublisher step add -
if (currentBuild.rawBuild.getLog(50).contains('[DependencyCheck] Findings exceed configured thresholds')) {
error("Build failed due to vulnerabilities found during dependencyCheck")
}else{
sh 'echo "No vulnerabilities found during dependencyCheck"'
}
For this you also need to allow rawBuild and getLog invocation permission from Jenkins. You can do it from Jenkins -> Manage Jenkins -> In-process Script Approval and allow both of them.(If you haven't allowed them then Jenkins build will fail and in the console output of the failed build you can find details regarding this)

Concourse: Use a semver resource to control which artifact to use from s3

My pipeline contains a task with the following pre-requisites
- get: version
trigger: true
params: { bump: patch }
passed: ["trigger_job [CI]"]
- get: sdk-package
passed: ["package_generation_job"]
params:
version: {path: "artifact_[I want to put the version here]"}
version is a semver stored in git; sdk-package is a build artifact stored in s3 where each run of the pipeline puts a new artifact using the version number as part of the name.
What I would like to do is used the version input to determine which version of the artifact is pulled from S3. Based on this I suspect that Concourse doesn't allow this, but I couldn't find a definitive answer.
This is not currently possible, you will have to download the artifact you want in a task script. You can pass the version into that task.

Resources