Publish Jar into Azure Artifact using gradle error - azure

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.

Related

Uploading Android native artifacts to Maven

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/...?

Android Studio: Failed to resolve: com.linkedin.android.litr:litr:1.1.0 while using cloudinary in my android app

I am building the android app that uses Cloudinary to upload images and videos. I am using AndroidX for both frontend and backend. I have all the related dependencies such as implementation 'com.cloudinary:cloudinary-android:1.30.0' and implementation 'com.linkedin.android.litr:litr:1.1.0', but on building the gradle I am getting the following error:
Failed to resolve: com.linkedin.android.litr:litr:1.1.0
Show in Project Structure dialog
Affected Modules: app
Failed to resolve: com.linkedin.android.litr:litr:1.1.0
Show in Project Structure dialog
Affected Modules: app
and upon running the app, I get the following error:
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.linkedin.android.litr:litr:1.1.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/linkedin/android/litr/litr/1.1.0/litr-1.1.0.pom
- https://repo.maven.apache.org/maven2/com/linkedin/android/litr/litr/1.1.0/litr-1.1.0.pom
- https://www.jitpack.io/com/linkedin/android/litr/litr/1.1.0/litr-1.1.0.pom
Required by:
project :app
project :app > com.cloudinary:cloudinary-android:1.30.0 > com.cloudinary:cloudinary-android-preprocess:1.30.0
* 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.
==============================================================================
Is there anything that I am missing or doing wrong? Any help would be appreciated.
try to type this line in the build.grade(project)
repositories {
maven{
url "https://maven.google.com"
} }

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 :(

Azure CD pipeline can't find build artifacts

Below is Azure error log from the Azure release pipeline.
2020-07-24T05:17:13.7712974Z ##[section]Starting: Deploy Azure App Service
2020-07-24T05:17:14.0464143Z ==============================================================================
2020-07-24T05:17:14.0465719Z Task : Azure App Service deploy
2020-07-24T05:17:14.0469391Z Description : Deploy to Azure App Service a web, mobile, or API app using Docker, Java, .NET, .NET Core, Node.js, PHP, Python, or Ruby
2020-07-24T05:17:14.0469849Z Version : 3.163.5
2020-07-24T05:17:14.0470410Z Author : Microsoft Corporation
2020-07-24T05:17:14.0470921Z Help : https://aka.ms/azureappservicetroubleshooting
2020-07-24T05:17:14.0471274Z =============================================================================
2020-07-24T05:17:16.0650643Z Got connection details for Azure App Service:'XXXXX'
2020-07-24T05:17:17.6576087Z (node:764) Warning: Use Cipheriv for counter mode of aes-256-ctr
**2020-07-24T05:17:17.6627737Z ##[error]Error: No package found with specified pattern: D:\a\r1\a\Drop<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.**
2020-07-24T05:17:22.9168975Z Successfully added release annotation to the Application Insight : XXXXX
2020-07-24T05:17:24.8686063Z Successfully updated deployment History at https://XXXXX.scm.azurewebsites.net/api/deployments/231595567842919
2020-07-24T05:17:24.8933576Z ##[section]Finishing: Deploy Azure App Service
P.S. I have checked build pipeline, I can download build Artificats, but it displays below warning.
[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build artifact 'drop'.
Assuming you meant you have solved the build artifact empty issue, but the release pipeline still had issue in Azure App Service deploy task.
As the error mentioned, there is "No package found with specified pattern: D:\a\r1\a\Drop", you need to check how you define the package, try format $(System.DefaultWorkingDirectory)/**/*.zip instead of $(System.DefaultWorkingDirectory)\Drop.
As task "Publish Build Artifact" publish artifact from $(build.artifactstagingdirectory), so we need add a task "Copy files" to copy your files ** from $(system.defaultworkingdirectory) to $(build.artifactstagingdirectory) **. which copied my build to stagingdirectory.

GAE migration from java 7 to 8 on android studio

I'm trying to migrate Google App Engine to java8 using the migration guide below.
https://cloud.google.com/appengine/docs/standard/java/migrating-to-java8
it says that: -
To have App Engine run your application in the Java 8 runtime, add
<runtime>java8</runtime>
to your appengine-web.xml file and redeploy the app.
when i try to do that i get the following error at the "runtime" tag:
element runtime is not allowed here
did i miss anything? This GAE is a backend module for my android app. I am using gradle on Android studio as the development environment.
prior to this, I have also migrated successfully to cloudEndpoints V2 using https://cloud.google.com/endpoints/docs/frameworks/java/migrating
edit: added error log
Jan 03, 2018 3:39:52 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
SEVERE: Received exception processing D:\GitlabProjects\XushuNarrator\backend\build\exploded-backend\WEB-INF/appengine-web.xml
com.google.apphosting.utils.config.AppEngineConfigException: Unrecognized element <runtime>
at com.google.apphosting.utils.config.AppEngineWebXmlProcessor.processSecondLevelNode(AppEngineWebXmlProcessor.java:183)
at com.google.apphosting.utils.config.AppEngineWebXmlProcessor.processXml(AppEngineWebXmlProcessor.java:65)
at com.google.apphosting.utils.config.AppEngineWebXmlReader.processXml(AppEngineWebXmlReader.java:132)
at com.google.apphosting.utils.config.AppEngineWebXmlReader.readAppEngineWebXml(AppEngineWebXmlReader.java:76)
at com.google.apphosting.utils.config.EarHelper.readWebModule(EarHelper.java:165)
at com.google.appengine.tools.development.ApplicationConfigurationManager$WarModuleConfigurationHandle.readConfiguration(ApplicationConfigurationManager.java:414)
at com.google.appengine.tools.development.ApplicationConfigurationManager.<init>(ApplicationConfigurationManager.java:159)
edit 2: the following is the gradle build for the backend. (After migration from V1 to V2)
//MIGRATION GUIDE
//https://cloud.google.com/endpoints/docs/frameworks/legacy/v1/java/migrating
buildscript {
repositories {
jcenter()
}
dependencies {
// V2: Add the new App Engine and Endpoints Frameworks plugin dependencies
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.2'
// classpath 'com.google.appengine:gradle-appengine-plugin:1.9.59'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
// V2: Apply new App Engine and Endpoints Framework server plugins
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
//apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
dependencies {
// appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.59'
// compile 'com.google.appengine:appengine-endpoints:1.9.59'
// compile 'com.google.appengine:appengine-endpoints-deps:1.9.59'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.googlecode.objectify:objectify:5.1.9'
compile 'javax.inject:javax.inject:1'
// V2: Endpoints Framework v2 migration
compile 'com.google.endpoints:endpoints-framework:2.0.7'
}
// V2: Define deployment configuration using the new App Engine plugin
// with the appengine closure
appengine { // App Engine tasks configuration
deploy { // deploy configuration
// The following is used for acceptance tests and
// is not required for a migration.
project = "ultra-tube-89909"
version = "2" //changed to GAE API v2
/*
Run the following command to initalize the Cloud SDK:
gcloud init
Use Application Default Credentials:
gcloud auth application-default login
Install the app-engine-java component:
gcloud components install app-engine-java
*/
// project = findProperty("appengine.deploy.project")
// version = findProperty("appengine.deploy.version")
def promoteProp = findProperty("appengine.deploy.promote")
if (promoteProp != null) {
promote = new Boolean(promoteProp)
}
}
}
It's highly advised to keep the Google Cloud SDK up to date as there are bug fixes and new features introduced quite often. So, I recommend that you to update your Cloud SDK version by the running the following command:
gcloud components update
Also, according to the migration documentation the following change is needed to upgrade the Gradle App Engine plugin, so that it may recognize the new ‘Java8’ runtime:
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3'
I had the exact same thing but even though I had the error
element runtime is not allowed here
I still redeployed the backend via Gradle and it all worked. Then when I check my google cloud console, the newly deployed app engine version has java 8 listed as the run time and my app still works. So all seems ok.

Resources