代码之家  ›  专栏  ›  技术社区  ›  JoseRivas1998

将libgdx核心发布到artifactory

  •  0
  • JoseRivas1998  · 技术社区  · 6 年前

    我正在尝试发布一个内部libGDX框架,用于我使用artifactory开发的所有游戏。我一直在跟踪 this guide 然而,我被困在项目本身实际发布的地方。我的libGDX项目只有一个核心模块,因为它本身不是游戏,所以我没有制作桌面或android模块。这是我整个项目的构建脚本

    buildscript {
    
    
        repositories {
            mavenLocal()
            mavenCentral()
            maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
            jcenter()
        }
        dependencies {
            classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
    
        }
    }
    
    allprojects {
        apply plugin: "eclipse"
        apply plugin: "idea"
    
        version = '1.0'
        ext {
            appName = "lichengine"
            gdxVersion = '1.9.8'
            roboVMVersion = '2.3.3'
            box2DLightsVersion = '1.4'
            ashleyVersion = '1.7.0'
            aiVersion = '1.8.0'
        }
    
        repositories {
            mavenLocal()
            mavenCentral()
            maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
            maven { url "https://oss.sonatype.org/content/repositories/releases/" }
        }
    }
    
    project(":core") {
        apply plugin: "java"
    
    
        dependencies {
            compile group: 'org.json', name: 'json', version: '20160810'
            compile "com.badlogicgames.gdx:gdx:$gdxVersion"
            compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
            compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
    
        }
    }
    
    tasks.eclipse.doLast {
        delete ".project"
    }
    

    这是核心模块的构建脚本

    apply plugin: "java"
    apply plugin: 'com.jfrog.artifactory'
    apply plugin: 'maven-publish'
    
    sourceCompatibility = 1.7
    [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
    
    sourceSets.main.java.srcDirs = [ "src/" ]
    
    
    eclipse.project {
        name = appName + "-core"
    }
    def libraryGroupId = 'my.com.lichengine'
    def libraryArtifactId = 'lichengine'
    def libraryVersion = '1.0'
    publishing {
        publications {
            aar(MavenPublication) {
                groupId libraryGroupId
                version libraryVersion
                artifactId libraryArtifactId
    
                artifact("$buildDir/publications/aar/${artifactId}-release.aar")
            }
        }
    }
    
    artifactory {
        contextUrl = 'http://mywebsite.com:8081/artifactory'
        publish {
            repository {
                repoKey = 'libs-release-local'
    
                username = artifactory_username
                password = artifactory_password
            }
            defaults {
                publications('aar')
                publishArtifacts = true
    
                properties = ['qa.level': 'basic', 'q.os': 'android', 'dev.team': 'core']
                publishPom = true
            }
        }
    }
    

    当我尝试运行 artifactoryPublish 根项目或核心项目上的任务我收到以下错误:

    lichengine\core\build\publications\aar\lichengine-release.aar' does not exist, and need to be published from publication aar

    我错过什么了吗?我在网上搜索的所有内容都是专门针对android库的,所以没有什么真正有用的。似乎应该生成的aar文件不是。

    1 回复  |  直到 6 年前
        1
  •  1
  •   JoseRivas1998    6 年前

    在经历了很多痛苦之后,我终于明白了。我使用的不是aar出版物,而是mavenJava。这是我的最新出版物块:

    publications {
            mavenJava(MavenPublication) {
                groupId libraryGroupId
                version libraryVersion
                artifactId libraryArtifactId
                from components.java
            }
        }
    

    我还必须更新默认块

    defaults {
                publications ('mavenJava')
                publishArtifacts = true
    
                properties = ['qa.level': 'basic', 'q.os': 'android', 'dev.team': 'core']
                publishPom = false
            }
    

    希望任何看到这一点的人都可以使用它来帮助他们使用artifactory创建libGDX库!