1

私の現在の目標は、Gradle を使用して、自分のマシンの Jetty インスタンスで実行されている Web アプリケーションを開始し、それに対して Selenium テストを記述できるようにすることです。Gretty プラグインが読み込まれているようですが、それを行うためのタスクを作成および構成する方法に関する実際の手順を見つけることができませんでした。

問題の一部は、Gretty プラグインのさまざまなバージョンやエディションとの混乱があることです。そもそもロードするだけでも試行錯誤でした。

私は Gradle 5.4.1 と Gretty 2.3.1 を使用しようとしていますが、これは現在のバージョンであると考えています (現時点では)。

「afl」に依存する「laoi」は「efl」に依存する 3 つのサブプロジェクトがあります。laoi ビルドは WAR ファイルを生成します。タスク appRunWar は、私のものを使用するのではなく、独自の WAR ファイルを作成して実行することを望んでいるようです (少なくとも、それが起こっているようです)。

settings.gradle:

rootProject.name = 'aoi'
include 'cm', 'efl', 'aofl', 'laoi', 'uiTest'

build.gradle (ラオイ):

static def getDate() {
    return new Date().format('yyyyMMdd-HHmmss')
}

final String timepickerAddonVersion = '1.6.3'
final String datatablesVersion = '1.10.19'
final String jqueryUIVersion = '1.12.1'
final String jqueryVersion = '3.2.1'

if (null == System.properties['aoi.release'] || null == System.properties['aoi.iteration']) {
    if (null == System.env['RELEASE'] || null == System.env['ITERATION']) {
        ext.ITERATION = "un"
        ext.RELEASE = "dev"
    } else {
        ext.ITERATION = System.env['ITERATION']
        ext.RELEASE = System.env['RELEASE']
    }
} else {
    ext.ITERATION = System.properties['aoi.iteration']
    ext.RELEASE = System.properties['aoi.release']
}
System.setProperty('aoi.iteration', ext.ITERATION)
System.setProperty('aoi.release', ext.RELEASE)

if (null == System.properties['aoi.manifest']) {
    if (null == System.env['MANIFEST']) {
        System.out.println("Using default manifest name.")
        ext.MANIFEST = "aoiManifest"
        System.out.println("Manifest: ${ext.MANIFEST}")
    } else {
        ext.MANIFEST = System.env['MANIFEST']
    }
} else {
    ext.MANIFEST = System.properties['aoi.manifest']
}
System.setProperty('aoi.manifest', ext.MANIFEST)
System.out.println("Manifest: ${ext.MANIFEST}")

final String warFileName = 'aoi-'+ System.properties['aoi.release'] +'_'+ System.properties['aoi.iteration'] + ".war"
println "War file name: ${warFileName}"

final String sourceManifestName = "${ext.MANIFEST}.xml"
println "Source manifest name: ${sourceManifestName}"

def rootLibs = new File("${rootDir}/libs")

repositories {
    mavenCentral()
    jcenter()
    flatDir {
        dirs "${rootDir}/libs"
    }
}


compileScala {
    dependsOn ":efl:test", ":aofl:test"
}

task copyManifest(type: Copy) {
    from('src/main/resources') {
        include sourceManifestName
        rename sourceManifestName, 'aoiManifest.xml'
    }
    into("${buildDir}/resources/main/bootstrap/liftweb")
}

task createVersionFile {
    dependsOn "processResources"
    doLast {
        new File("${buildDir}/resources/main/aoiVersion.conf").text = "AOI_VERSION=" + System.properties['aoi.release'] +'-'+ System.properties['aoi.iteration'] + " (" + getDate() + ")"
        new File("${buildDir}/resources/main/WebJarVersions.conf").text =
"""jQuery-Timepicker-Addon=$timepickerAddonVersion
datatables=$datatablesVersion
jquery=$jqueryVersion
jquery-ui=$jqueryUIVersion
jquery-ui-themes=$jqueryUIVersion
"""
    }
}

war {
    dependsOn ":aofl:test", "compileScala", "copyManifest", "processResources", "createVersionFile"
    setDestinationDirectory(rootLibs)

    setArchiveFileName(warFileName)

    from('${buildDir}/resources/main') {
        include '**/*.xml'
        into("classes")
    }
}

dependencies {
    implementation project(":efl")
    implementation project(":aofl")
    implementation "org.webjars:jquery:$jqueryVersion"
    implementation "org.webjars:jquery-ui:$jqueryUIVersion"
    implementation "org.webjars:jquery-ui-themes:$jqueryUIVersion"
    implementation "org.webjars:datatables:$datatablesVersion"
    implementation "org.webjars:jQuery-Timepicker-Addon:$timepickerAddonVersion"
    implementation 'org.webjars:webjars-servlet-2.x:1.1'
}
4

1 に答える 1