Uploading different jars to Artifactory with gradle - plugins

Is it possible to conditionally upload jars to artifactory?
I have tried using the Artifactory plugin but that works fine if the case is just to upload a single jar from a build pipeline.
If I also want to upload a test jar, how would that go?
Can I have some configuration specifying which jar should be uploaded? e.g. test jar or the "normal" jar file
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
artifactory {
clientConfig.setIncludeEnvVars(true)
contextUrl = 'https://localhost:8081/artifactory/'
publish {
repository {
repoKey = 'libs-release-local'
username = "${artifactory_user}"
password = "${artifactory_user_password}"
}
defaults {
publications('mavenJava')
publishArtifacts = true
publishPom = true
publishIvy = true
}
}
resolve {
contextUrl = 'https://localhost:8081/artifactory'
repository {
repoKey = 'libs-release-local'
username = "${artifactory_user"
password = "${artifactory_user_password}"
maven = true
}
}
}

To publish classes from your test SourceSet (src/test/ by default), you first need to define a task to create the testJar:
task testJar(type: Jar) {
classifier = 'tests'
from sourceSets.test.output
}
Then add it to your publications
publications {
mavenJava(MavenPublication) {
from components.java
artifact testJar {
classifier "test"
}
}
}
Since you're already publishing publications('mavenJava') from artifactory, you do not have to make any changes there.

Related

GitHub Projects Beta - How to get the data from a view in the API

My company is using the new GitHub projects beta and we're really enjoying the experience, but we're facing a problem and it is how to export the data from a specific view (or even all the data) with all the custom columns that we have.
The ideal solution for us is to get this same data as JSON using the API.
Using https://api.github.com/orgs/.../issues does not work because the issues does not have the custom columns that we create inside the project, and https://api.github.com/orgs/.../projects does not have the data of the issues.
Any idea or work-around to get this data easily using APIs?
After reading the feedback post on GitHub, it's not possible to do it with API, just GraphQL, at least for now.
So my problem was solved with this useful code.
To get the first 100 project from your organization and their ID:
query{
organization(login: "MY_ORG") {
projectsNext(first: 20) {
nodes {
id
title
}
}
}
}
To get the first 100 issues and drafts from a specific project:
{
node(id: "My_Project_ID") {
... on ProjectNext {
items(first: 100, after: null) {
edges {
cursor
}
nodes {
content {
... on Issue {
title
assignees(first: 1) {
nodes {
login
}
}
milestone {
title
}
labels(first: 5) {
nodes {
name
}
}
repository{
name
}
}
}
fieldValues(first: 15) {
nodes {
value
projectField {
name
settings
}
}
}
}
}
}
}
}
Those codes can be easily tested in THIS LINK

Detecting installed plugin in Eclipse

I'd like to detect the presence of a plugin from within the Eclipse plugin I'm maintaining. From a few other questions asked on this subject it looks like this is difficult.
The plugin I'm looking to detect provides a view. As such the following works, but I'm hoping that a prettier option exists:
public static boolean internalPluginInstalled() {
IExtensionRegistry reg = Platform.getExtensionRegistry();
IExtensionPoint point = reg.getExtensionPoint("org.eclipse.ui.views");
IExtension[] extensions = point.getExtensions();
for(IExtension extension : extensions) {
IConfigurationElement[] configs = extension.getConfigurationElements();
for (IConfigurationElement config : configs) {
if (config.getName().equals("view") && config.getAttribute("id").equals("view.id.goes.here")) {
return true;
}
}
}
return false;
}
Use Platform.getBundle (org.eclipse.core.runtime.Platform):
Bundle bundle = Platform.getBundle("plugin id");
bundle will be non-null if the plug-in is installed.
bundle.getState() returns you the exact state of the plug-in - Bundle.ACTIVE if the plug-in has been started.

Jenkins Multibranch-Pipeline JobDSL can't specify github url

I'm creating a Multibranch Pipeline job with JobDSL , and I want to specify my github url , but it's not working.
The job which I created it display "https://github.com/jackson/multibranch-Pipeline.git" ,
not https://mycompanygithub.com/jackson/multibranch-Pipeline.git
Any idea how theses other parameters can be added in ?
or other solution
multibranchPipelineJob('Jenkins/Multibranch-Pipeline/GitHub_Basic') {
branchSources {
branchSource {
source {
github {
repositoryUrl('https://mycompanygithub.com')
credentialsId('mycredentialsid')
repoOwner('jackson')
repository('multibranch-Pipeline.git')
configuredByUrl(true)
}
}
}
}
}
Actually your configuration is correct, your are just missing one parameter: apiUri
// The server to connect to.
apiUri(String value)
Without it, it takes the default github.com as the base domain for the repository regardless of what is configured in the repositoryUrl parameter.
Try the following:
multibranchPipelineJob('Jenkins/Multibranch-Pipeline/GitHub_Basic') {
branchSources {
branchSource {
source {
github {
apiUri('https://mycompanygithub.com/api/v3')
repositoryUrl('https://mycompanygithub.com')
credentialsId('mycredentialsid')
repoOwner('jackson')
repository('multibranch-Pipeline.git')
configuredByUrl(true)
}
}
}
}
}
By the way you can see the full documentation of the Job DSL of this plugin at the following URL on your own Jenkins server:
YOUR_JENKINS_URL/plugin/job-dsl/api-viewer/index.html#method/javaposse.jobdsl.dsl.DslFactory.multibranchPipelineJob

Initially publishing a github package shows "Username must not be null!"

I am trying to publish a package on Github using the Gradle part in Android Studio. It is not my first one but I cannot find what the difference is to the previous ones and why I get this error.
I can successfully run the build step and the files are in the output folder. However, when I run the step "publish", I get the following error:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task
':config_properties_reader_android:publishBarPublicationToGitHubPackagesRepository'.
Failed to publish publication 'bar' to repository 'GitHubPackages'
-> Username must not be null!
The only difference I could find was that my module folder with the files to publish contains three instead of the usual two files:
Those two I would expect:
config_properties_reader_android/build/outputs/aar/config_properties_reader_android-debug.aar
config_properties_reader_android/build/outputs/aar/config_properties_reader_android-release.aar
And this one seems odd:
config_properties_reader_android/build/outputs/aar/configpropertiesreader-debug.aar
My gradle file looks like this:
apply plugin: 'maven-publish'
def githubProperties = new Properties()
githubProperties.load(new FileInputStream(rootProject.file("github.properties")))
def getVersionName = { ->
return "1.0.0"
}
def getArtificatId = { ->
return "config_properties_reader_android"
}
publishing {
publications {
bar(MavenPublication) {g
groupId 'com.MyGithubRepo'
artifactId getArtificatId()
version getVersionName()
artifact("$buildDir/outputs/aar/${getArtificatId()}-release.aar")
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/MyGithubRepo/ConfigPropertiesReader.Android")
credentials {
username = githubProperties['gpr.usr'] ?: System.getenv("GPR_USER")
password = githubProperties['gpr.key'] ?: System.getenv("GPR_API_KEY")
}
}
}
}
And my github.properties file also contains the usual:
gpr.user=myUser
gpr.key=myKey
Could the third file in the ouput folder be the problem? I do not see how the username should have anything to do with it but I have no idea where to look in order to find the error.
Try this in github.properties file
gpr.usr=myUser
gpr.key=myKey
Change gpr.user => gpr.usr
Also, use your git user-id in gpr.usr
and use git personal access token in gpr.key
i also have this issue this change solve mine problem
check the below line and replace the username and password it will work
file name is build.gradle
maven {
url "https://cardinalcommerceprod.jfrog.io/artifactory/android"
credentials {
username 'braintree_team_sdk'
password 'AKCp8jQcoDy2hxSWhDAUQKXLDPDx6NYRkqrgFLRc3qDrayg6rrCbJpsKKyMwaykVL8FWusJpp'
}
}

Could not find com.huawei.agconnect:agcp:1.0.0.300

Could not find com.huawei.agconnect:agcp:1.0.0.300.
Searched in the following locations:
- https://jcenter.bintray.com/com/huawei/agconnect/agcp/1.0.0.300/agcp-1.0.0.300.pom
- https://jcenter.bintray.com/com/huawei/agconnect/agcp/1.0.0.300/agcp-1.0.0.300.jar
- https://dl.google.com/dl/android/maven2/com/huawei/agconnect/agcp/1.0.0.300/agcp-1.0.0.300.pom
- https://dl.google.com/dl/android/maven2/com/huawei/agconnect/agcp/1.0.0.300/agcp-1.0.0.300.jar
Required by:
project :
I am following this document but still facing issue.
https://developer.huawei.com/consumer/en/codelab/HMSAnalyticsKit/index.html#2
Can anyone help?
Looks like you are missed to add application gradle configurations.
Try after adding these lines on your gradle file
buildscript {
repositories {
maven { url 'http://developer.huawei.com/repo/' }
}
dependencies {
classpath 'com.huawei.agconnect:agcp:1.2.0.300'
}
}
allprojects {
repositories {
maven { url 'http://developer.huawei.com/repo/' }
}
}
Though your environment is built based on the codelab of Analytics Kit, but the AppGallery Connect plug-in is not configured correctly, so you cannot find it. Configure it by referring to the guide at the link.
Make sure to use the current version; it's more alike this:
buildscript {
repositories {
google()
mavenCentral()
maven { url "https://developer.huawei.com/repo/" }
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
classpath "com.huawei.agconnect:agcp:1.6.0.300"
}
}