Commit 32c2d404 authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

Migrating search to Gradle

parent 7915f6c6
Loading
Loading
Loading
Loading
Loading
+82 −29
Original line number Diff line number Diff line
# ---> Java
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# ---> Eclipse
*.pydevproject
### Eclipse ###
.metadata
.gradle
bin/
tmp/
*.tmp
@@ -25,9 +9,7 @@ tmp/
local.properties
.settings/
.loadpath

# Eclipse Core
.project
.recommenders

# External tool builders
.externalToolBuilders/
@@ -35,29 +17,100 @@ local.properties
# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# JDT-specific (Eclipse Java Development Tools)
.classpath
# CDT- autotools
.autotools

# Java annotation processor (APT)
.factorypath

# PDT-specific
# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

/target/
# STS (Spring Tool Suite)
.springBeans

# Sphinx build
/docs/_build/
/docs/venv/
# Code Recommenders
.recommenders/

.springBeans
# Annotation Processing
.apt_generated/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

### Eclipse Patch ###
# Eclipse Core
.project

# JDT-specific (Eclipse Java Development Tools)
.classpath

# Annotation Processing
.apt_generated

.sts4-cache/

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### Java-Web ###
## ignoring target file
target/

### Gradle ###
.gradle
build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties

### Gradle Patch ###
**/build/
+21 −55
Original line number Diff line number Diff line
image: maven:latest
image: java:8-jdk

variables:
  MAVEN_CLI_OPTS: "--batch-mode"
  GIT_SUBMODULE_STRATEGY: recursive
  GRADLE_OPTS: "-Dorg.gradle.daemon=false"
  NEXUS_CREDENTIALS: "-Pnexususer=$NEXUS_REPO_USER -Pnexuspass=$NEXUS_REPO_PASS"

before_script:
  - VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
  - ARTIFACT=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
  - export GRADLE_USER_HOME=`pwd`/.gradle
  - ./gradlew wrapper --gradle-version=5.6.4 --distribution-type=bin

cache:
  paths:
    - .gradle/wrapper
    - .gradle/caches

stages:
  - build
  - deploy
  
build:
  stage: build
  script:
    - mvn $MAVEN_CLI_OPTS clean compile

test:
  stage: test
  script:
    - mvn $MAVEN_CLI_OPTS test
  script: ./gradlew assemble

deploy:
  stage: deploy
  script:
    - |
      if [[ $VERSION = *"SNAPSHOT" || $VERSION = *"RELEASE" ]]; then
        echo "Building Debian package for $VERSION"
        mvn $MAVEN_CLI_OPTS -U -Pdariah.deb -Dmaven.test.failure.ignore package

        echo "Building documentation for $ARTIFACT $VERSION"
        cd docs

        echo "-- Setting up Virtualenv"
        virtualenv venv
        pwd
        . venv/bin/activate
    - ./gradlew publish -x test :search-docs:publish $NEXUS_CREDENTIALS

        echo "-- Installing requirements"
        pip install -r requirements.txt

        echo "-- Building HTML version within $(pwd)"
        make clean html

        echo "-- Creating package"
        fpm -t deb -a noarch -s dir --name search-doc \
                              --description='DARIAH-DE Generic Search Documentation' \
                              --maintainer='DARIAH-DE <info@de.dariah.eu>' \
                              --vendor='DARIAH-DE' \
                              --url='https://search.de.dariah.eu' \
                              --version $VERSION \
                              -x ".git**" \
                              -x "**/.git**" \
                              -x "**/.hg**" \
                              -x "**/.svn**" \
                              -x ".buildinfo" \
                              -x "**/*.deb" \
                              --prefix /var/www/doc/search \
                              -C _build/html .

        mv *.deb ../target
        
        ~/scripts/push_deb_packages.sh ../target
        
      fi
  only:
    - master
    - mww
 No newline at end of file
docs:
  stage: deploy
  script:
    - ./gradlew :search-docs:publish $NEXUS_CREDENTIALS 
 No newline at end of file

build.gradle

0 → 100644
+246 −0
Original line number Diff line number Diff line
buildscript {
    repositories {
        //maven { url 'https://repo.spring.io/plugins-snapshot' }
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        //classpath 'io.spring.gradle:dependency-management-plugin'
        classpath 'com.netflix.nebula:gradle-ospackage-plugin'
    }
}

plugins {
    id 'war'
    //id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'maven-publish'
    id 'nebula.ospackage' version '8.0.3'
}

allprojects {
    group = 'eu.dariah.de.minfba'
    version = '3.7.13-SNAPSHOT'
    description = 'DARIAH-DE Generic Search'
    
    ext {
        mavenRepo     = 'https://minfba.de.dariah.eu/nexus/repository/minfba-central/'
        releasesRepo  = "https://minfba.de.dariah.eu/nexus/repository/minfba-releases/"
        snapshotsRepo = "https://minfba.de.dariah.eu/nexus/repository/minfba-snapshots/"
        aptRepo       = 'https://minfba.de.dariah.eu/nexus/repository/minfba-apt/'
        yumRepo       = 'https://minfba.de.dariah.eu/nexus/repository/minfba-yum/'
        
        repoUser = project.hasProperty('nexususer') ? project.getProperty('nexususer') : '?';
        repoPass = project.hasProperty('nexuspass') ? project.getProperty('nexuspass') : ''
    }
}

repositories {
    mavenLocal()
    maven {
        url = mavenRepo
    }
}

sourceCompatibility = '1.8'

ext {
    searchCommonsVersion = "1.17.0-SNAPSHOT"

    springVersion = "4.3.6.RELEASE"
        hibernateValidatorVersion = "5.2.2.Final"
        tilesVersion = "3.0.5"
        slf4jVersion = "1.7.25"
        httpComponentsVersion = "4.5.5"
        logbackVersion = "1.2.3"

    // Filled dynamically by packaging tasks
    debFile = ""
    rpmFile = ""
}

dependencies {
    implementation "eu.dariah.de.minfba:search-commons:$searchCommonsVersion"
    implementation "org.springframework:spring-context:$springVersion"
    implementation "org.springframework:spring-beans:$springVersion"
    implementation "org.springframework:spring-core:$springVersion"
    implementation "org.springframework:spring-webmvc:$springVersion"
    implementation "org.springframework:spring-web:$springVersion"
    //implementation "org.springframework.security:spring-security-core:4.2.1.RELEASE"
    //implementation "org.springframework.security:spring-security-web:4.2.1.RELEASE"
    //implementation "org.springframework.security:spring-security-config:4.2.1.RELEASE"
    implementation "org.apache.httpcomponents:httpclient:$httpComponentsVersion"
    implementation "org.apache.tiles:tiles-core:$tilesVersion"
    implementation "org.apache.tiles:tiles-jsp:$tilesVersion"
    implementation "org.apache.tiles:tiles-api:$tilesVersion"
    implementation "org.slf4j:slf4j-api:$slf4jVersion"
    implementation "ch.qos.logback:logback-core:$logbackVersion"
    implementation "ch.qos.logback:logback-classic:$logbackVersion"
    implementation "javax.servlet:jstl:1.2"
    implementation "org.yaml:snakeyaml:1.18"
    runtimeOnly "org.slf4j:jcl-over-slf4j:$slf4jVersion"
    runtimeOnly "org.slf4j:log4j-over-slf4j:$slf4jVersion"
    runtimeOnly "org.apache.logging.log4j:log4j-to-slf4j:2.7"
    testImplementation "org.springframework:spring-test:$springVersion"
    testImplementation "junit:junit:4.12"
    testImplementation "org.mockito:mockito-all:1.10.19"
    providedCompile "javax.servlet:servlet-api:2.5"
    providedCompile "javax.servlet.jsp:jsp-api:2.1"
}


java {
    sourceCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives sourcesJar
    archives javadocJar
}

tasks.withType(Deb) {
    dependsOn(classes)
    doLast {
        project.debFile = archiveName;
    }
}

tasks.withType(Rpm) {
    dependsOn(classes)
    doLast {
        project.rpmFile = archiveName;
    }
}

ospackage {
    os = LINUX
    arch = 'noarch'
    packageName "dariah-$project.name"
    replaces "$project.name"
    maintainer 'info@de.dariah.eu'
    requires('openjdk-8-jdk').or('openjdk-11-jdk')
    signingKeyId('CB012F105B632B46C2A7B4918FC46DAC1BC3E238')

    into "var/dfa/webapps/$project.name/"

    from(configurations.runtime) {
        into "WEB-INF/lib"
    }

    from("$buildDir/classes/java/main") {
        into "WEB-INF/classes"
    }

    from ("src/main/resources") {
        into "WEB-INF/classes"
    }

    from ("src/main/webapp/WEB-INF") {
        into "WEB-INF"
    }

    from ("src/main/webapp/resources") {
        into "resources"
    }

    from ("src/main/webapp/themes") {
        into "themes"
    }

    from ("src/main/webapp/META-INF") {
        into "META-INF"
    }
}

publishing {
    publications {
        maven(MavenPublication) {
            from(components.web)
            artifact(sourcesJar) {}
            artifact(javadocJar) {}
            pom {
                name = 'DARIAH-DE Generic Search'
                url = 'https://gitlab.rz.uni-bamberg.de/dariah/search'
                licenses {
                    license {
                        name = 'The Apache License, Version 2.0'
                        url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id = 'tgradl'
                        name = 'Tobias Gradl'
                        email = 'tobias.gradl@uni-bamberg.de'
                    }
                }
                scm {
                    connection = 'scm:git:git://gitlab.rz.uni-bamberg.de/dariah/search.git'
                    developerConnection = 'scm:git:ssh://gitlab.rz.uni-bamberg.de/dariah/search.git'
                    url = 'https://gitlab.rz.uni-bamberg.de/dariah/search'
                }
                issueManagement {
                    system = 'GitLab'
                    url = 'https://gitlab.rz.uni-bamberg.de/dariah/search/issues'
                }
            }
        }
    }
    repositories {
        maven {            
            if (version.endsWith('SNAPSHOT') || version.endsWith('RELEASE')) {
                credentials {
                    username repoUser
                    password repoPass
                }
                url = version.endsWith('SNAPSHOT') ? snapshotsRepo : releasesRepo
            } else {
                // Have a local test repo under buildDir to be able to test publish but only actually do publish when the version ending matches
                url = "$buildDir/repo/"
            }
        }
    }
}

task publishDebPackage {
    dependsOn buildDeb
    def distroPath = "$buildDir/distributions/"
    doLast {
        if (version.endsWith('SNAPSHOT') || version.endsWith('RELEASE')) {
            println "Publishing Debian package $debFile as user $repoUser";
            exec {
                executable "curl"
                args "-f", "-u", "$repoUser:$repoPass", "-H", "Content-Type: multipart/form-data", "--data-binary", "@$distroPath$debFile", "$aptRepo";
            }
        }
    }
}

task publishRpmPackage {
    dependsOn buildRpm
    def distroPath = "$buildDir/distributions/"
    doLast {
        if (version.endsWith('SNAPSHOT') || version.endsWith('RELEASE')) {
            println "Publishing Rpm package $rpmFile as user $repoUser";
            exec {
                executable "curl"
                args "-f", "-u", "$repoUser:$repoPass", "--upload-file", "$distroPath$rpmFile", "$yumRepo/dariah/${project.name}/${project.version}/$rpmFile";
            }
        }
    }
}

publish.finalizedBy publishDebPackage
publish.finalizedBy publishRpmPackage
 No newline at end of file

docs/.gitattributes

0 → 100644
+6 −0
Original line number Diff line number Diff line
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat           text eol=crlf
+5 −1
Original line number Diff line number Diff line
/_build/
 No newline at end of file
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
Loading