Skip to content

Commit

Permalink
Adjustment to UI Deployment (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo authored Sep 19, 2024
1 parent ce226fd commit 00c0522
Show file tree
Hide file tree
Showing 13 changed files with 185 additions and 69 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
run: ./gradlew printJavaVersion
- name: Assemble
timeout-minutes: 10
run: ./gradlew assemble
run: ./gradlew assemble -PwithoutpullingUi=true
- name: Build Plugins
timeout-minutes: 5
run: ./gradlew assemblePlugins
run: ./gradlew assemblePlugins -PwithoutpullingUi=true
- name: Execute integration tests for ${{ matrix.adapter }}
timeout-minutes: 30
run: ./gradlew integrationTests -Dstore.default=${{ matrix.adapter }}
run: ./gradlew integrationTests -Dstore.default=${{ matrix.adapter }} -PwithoutpullingUi=true
6 changes: 3 additions & 3 deletions .github/workflows/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
run: ./gradlew printJavaVersion
- name: Assemble
timeout-minutes: 60
run: ./gradlew assemble
run: ./gradlew assemble -PwithoutpullingUi=true
- name: Build Plugins
timeout-minutes: 60
run: ./gradlew assemblePlugins
run: ./gradlew assemblePlugins -PwithoutpullingUi=true
- name: Execute tests
timeout-minutes: 30
run: ./gradlew check
run: ./gradlew check -PwithoutpullingUi=true
6 changes: 3 additions & 3 deletions .github/workflows/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
run: ./gradlew printJavaVersion
- name: Assemble
timeout-minutes: 60
run: ./gradlew assemble
run: ./gradlew assemble -PwithoutpullingUi=true
- name: Build Plugins
timeout-minutes: 60
run: ./gradlew assemblePlugins
run: ./gradlew assemblePlugins -PwithoutpullingUi=true
- name: Execute tests
timeout-minutes: 30
run: ./gradlew -p plugins test
run: ./gradlew -p plugins test -PwithoutpullingUi=true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Generated files
gen/

# webapp
webui/src/main/resources/webapp/*


# Created by .ignore support plugin (hsz.mobi)
Expand Down
3 changes: 3 additions & 0 deletions config/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ group "org.polypheny"
dependencies {
implementation group: "io.javalin", name: "javalin", version: javalin_version // Apache 2.0

implementation group: 'net.lingala.zip4j', name: 'zip4j', version: zip4j_version // Apache 2.0


implementation group: "com.google.code.gson", name: "gson", version: gson_version // Apache 2.0

implementation group: "com.fasterxml.jackson.core", name: "jackson-databind", version: jackson_databind_version // Apache 2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.Optional;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import org.jetbrains.annotations.NotNull;


Expand Down Expand Up @@ -269,8 +271,17 @@ public File registerNewFolder( String folder ) {
}


public File registerNewGlobalFolder( String testBackup ) {
return registerNewFolder( this.root, testBackup );
public File registerNewGlobalFolder( String folder ) {
return registerNewFolder( this.root, folder );
}


public void unzipInto( File zip, File target ) {
try {
new ZipFile( zip ).extractAll( target.getAbsolutePath() );
} catch ( ZipException e ) {
throw new RuntimeException( "Could not unzip: {}", e );
}
}


Expand All @@ -279,8 +290,13 @@ public boolean isAccessible( File file ) {
}


public File getRootPath() {
public File getHomePath() {
return home;
}


public File getRootPath() {
return root;
}

}
6 changes: 3 additions & 3 deletions dbms/src/main/java/org/polypheny/db/PolyphenyDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void runPolyphenyDb() {
throw new GenericRuntimeException( "Unable to backup the Polypheny folder since there is already a backup folder." );
}
File backupFolder = dirManager.registerNewFolder( "_test_backup" );
for ( File item : dirManager.getRootPath().listFiles() ) {
for ( File item : dirManager.getHomePath().listFiles() ) {
if ( item.getName().equals( "_test_backup" ) ) {
continue;
}
Expand Down Expand Up @@ -458,7 +458,7 @@ private static void restoreHomeFolderIfNecessary( PolyphenyHomeDirManager dirMan
if ( dirManager.getHomeFile( "_test_backup" ).isPresent() && dirManager.getHomeFile( "_test_backup" ).get().isDirectory() ) {
File backupFolder = dirManager.getHomeFile( "_test_backup" ).get();
// Cleanup Polypheny folder
for ( File item : dirManager.getRootPath().listFiles() ) {
for ( File item : dirManager.getHomePath().listFiles() ) {
if ( item.getName().equals( "_test_backup" ) ) {
continue;
}
Expand All @@ -471,7 +471,7 @@ private static void restoreHomeFolderIfNecessary( PolyphenyHomeDirManager dirMan
// Restore contents from backup
for ( File item : backupFolder.listFiles() ) {
if ( dirManager.getHomeFile( "_test_backup/" + item.getName() ).isPresent() ) {
if ( !item.renameTo( new File( dirManager.getRootPath(), item.getName() ) ) ) {
if ( !item.renameTo( new File( dirManager.getHomePath(), item.getName() ) ) ) {
throw new GenericRuntimeException( "Unable to restore the Polypheny folder." );
}
}
Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ commons_io_version = 2.15.1
commons_lang3_version = 3.16.0
cottontaildb_version = 0.13.3
cottontaildb_driver_version = 0.13.0
cottontaildb_eclipse_version = 7.1.2
cottontaildb_guave_version = 15.0
cottontaildb_kotlin_version = 1.2.41
cottontaildb_mapdb_version = 3.0.8
cottontaildb_grpc_version = 1.36.0
esri_geometry_api_version = 2.2.0
google_api_client_version = 1.33.0
Expand Down Expand Up @@ -92,3 +96,4 @@ slf4j_api_version = 2.0.16
typesafe_config_version = 1.2.1
unirest_version = 3.14.5
web3j_version = 5.0.0
zip4j_version = 2.11.5
35 changes: 20 additions & 15 deletions plugins/cottontail-adapter/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
plugins {
id "org.jetbrains.kotlin.jvm" version "1.7.22"
id("de.undercouch.download") version "5.6.0"
}

configurations {
preDependencyConfig
}

group "org.polypheny"

apply plugin: "kotlin"


dependencies {
compileOnly project(":core")
compileOnly project(":plugins:sql-language")

implementation group: "io.grpc", name: "grpc-all", version: cottontaildb_grpc_version
// Cottontail DB
implementation(group: "org.vitrivr", name: "cottontaildb", version: cottontaildb_version)
implementation group: "org.vitrivr", name: "cottontaildb-proto", version: cottontaildb_driver_version

// Cottontail DB Dependencies (necessary due to dbisnexus shutdown)
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: cottontaildb_kotlin_version
implementation group: 'org.eclipse.collections', name: 'eclipse-collections-api', version: cottontaildb_eclipse_version
implementation group: 'org.eclipse.collections', name: 'eclipse-collections', version: cottontaildb_eclipse_version
implementation group: 'org.eclipse.collections', name: 'eclipse-collections-forkjoin', version: cottontaildb_eclipse_version
implementation group: 'com.google.guava', name: 'guava', version: cottontaildb_guave_version
implementation group: 'org.mapdb', name: 'mapdb', version: cottontaildb_mapdb_version

// Cottontail DB
implementation group: 'org.vitrivr', name: 'cottontaildb', version: cottontaildb_version
implementation group: 'org.vitrivr', name: 'cottontaildb-proto', version: cottontaildb_driver_version

// --- Test Compile ---
testImplementation project(path: ":dbms", configuration: "test")
Expand All @@ -23,6 +37,7 @@ dependencies {
testImplementation project(path: ":core")
}


compileKotlin {
dependsOn(":plugins:sql-language:processResources")
}
Expand All @@ -36,14 +51,6 @@ delombok {
dependsOn(":plugins:sql-language:processResources")
}

/*inspectClassesForKotlinIC {
dependsOn(":plugins:cottontail-adapter:compileTestKotlin")
}
plugin {
dependsOn(":plugins:cottontail-adapter:compileTestKotlin")
}*/

test.dependsOn(":dbms:shadowJar")


Expand Down Expand Up @@ -79,16 +86,12 @@ jar {
attributes "Copyright": "The Polypheny Project (polypheny.org)"
attributes "Version": "$project.version"
}
//dependsOn(":plugins:cottontail-adapter:compileTestKotlin")
}
java {
withJavadocJar()
withSourcesJar()
}

javadoc {
//dependsOn(":plugins:cottontail-adapter:compileTestKotlin")
}

licensee {
allow('Apache-2.0')
Expand All @@ -107,4 +110,6 @@ licensee {
allowDependency('org.vitrivr', 'cottontaildb-proto', '0.13.0') { because 'MIT license' }

allowDependency('javax.annotation', 'javax.annotation-api', '1.3.2') { because 'CDDL license' }

allowDependency('net.jcip', 'jcip-annotations', '1.0') { because 'transitive, Apache 2. according to github' }
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ public void run() {
}
} ) );
config.enableCorsForAllOrigins();
config.addStaticFiles( staticFileConfig -> staticFileConfig.directory = "webapp/" );
} ).start( port );
server.exception( Exception.class, ( e, ctx ) -> {
log.warn( "Caught exception in the HTTP interface", e );
Expand Down Expand Up @@ -287,4 +286,4 @@ public void remove() {

}

}
}
66 changes: 48 additions & 18 deletions webui/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id("de.undercouch.download") version "5.6.0"
}

group "org.polypheny"


Expand All @@ -16,7 +20,7 @@ dependencies {
implementation project(":core")
implementation project(":monitoring")

uiFiles group: "org.polypheny", name: "polypheny-ui", version: polypheny_ui_version
//uiFiles group: "org.polypheny", name: "polypheny-ui", version: polypheny_ui_version

implementation group: "commons-io", name: "commons-io", version: commons_io_version // Apache 2.0
implementation group: "io.javalin", name: "javalin", version: javalin_version // Apache 2.0
Expand All @@ -39,7 +43,7 @@ sourceSets {
srcDirs = ["src/main/java"]
}
resources {
srcDirs = ["src/main/resources", "$buildDir/webapp"]
srcDirs = ["src/main/resources", "build/resources/main"]
}
output.resourcesDir = file(project.buildDir.absolutePath + "/classes")
}
Expand All @@ -59,29 +63,56 @@ compileJava {
dependsOn(":monitoring:processResources")
}


processResources {
dependsOn(":webui:unzipUiFiles")
setDuplicatesStrategy(DuplicatesStrategy.WARN)
if (!project.hasProperty('withoutpullingUi')) {
dependsOn(":webui:downloadUiZip")
}
}


gradle.taskGraph.whenReady { taskGraph ->
if (!project.hasProperty('withoutpullingUi')
&& !layout.buildDirectory.get().file("polypheny-ui.zip").asFile.exists()) {
println("Pulling UI files")
handleUi.dependsOn downloadUiZip
}
}

task downloadUiZip(type: Download) {
src 'https://artifacts.polypheny.com/ui/polypheny-ui.zip'
dest "${layout.buildDirectory.asFile.get().absolutePath}/classes/polypheny-ui.zip"
overwrite true
onlyIfModified true
}

private Object getPolyphenyHome() {
def homeDir = System.getProperty('user.home');
def polyphenyDir = System.getenv('POLYPHENY_HOME') ?: "${homeDir}/.polypheny"
polyphenyDir
}

// unzip ui files
task unzipUiFiles(type: Copy) {
from zipTree(configurations.uiFiles.singleFile)
into "$buildDir/webapp"
doLast {
file("$buildDir/webapp/index").mkdirs()
ant.move file: "$buildDir/webapp/webapp/index.html",
toDir: "$buildDir/webapp/index/"
task deleteUiOverwrite() {
def home = getPolyphenyHome()
def ui = file("${home}/ui")
if (ui.exists() && ui.canWrite()) {
delete ui
}
}
tasks.register('deleteUiFiles') {
project.delete(
fileTree("$buildDir/webapp")
)

clean.dependsOn(deleteUiOverwrite)

build.dependsOn(":webui:handleUi")


task handleUi() {
// empty on purpose due to gradle weirdness
}
unzipUiFiles.dependsOn(deleteUiFiles)
classes.dependsOn(unzipUiFiles)

if (!project.hasProperty('withoutpullingUi')) {
handleUi.finalizedBy downloadUiZip
}

/**
* JARs
Expand All @@ -92,7 +123,6 @@ jar {
attributes "Copyright": "The Polypheny Project (polypheny.org)"
attributes "Version": "$project.version"
}
from("$buildDir/webapp") // include webapp files
duplicatesStrategy = 'include'
}
java {
Expand Down
Loading

0 comments on commit 00c0522

Please sign in to comment.