plugins {
    id 'java-library'
    id 'maven-publish'
    id 'eclipse-wtp'
    id 'idea'
}

group 'com.eactive'
version '4.5.1-SNAPSHOT'


def springVersion = "5.3.27"

def nexusUrl = "https://nexus.eactive.synology.me:8090"


java {
	toolchain {
		languageVersion = JavaLanguageVersion.of(8)
	}
}

compileJava {
    options.encoding = 'UTF-8'
}

jar {
	exclude '**/persistence.xml'
}

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


dependencies {
    //implementation project(':elink-online-core')
    //implementation project(':elink-online-transformer')
    //implementation project(':elink-online-common')
    api project(':elink-online-common')
    
    compileOnly fileTree(dir: 'libs', include: ['*.jar'])

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

test {
    useJUnitPlatform()
}

publishing {
    repositories {
        maven {
            name = 'eactiveRepository'
            def releasesRepoUrl = "${nexusUrl}/repository/maven-releases/"
            def snapshotsRepoUrl = "${nexusUrl}/repository/maven-snapshots/"
            url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
            credentials(PasswordCredentials)
        }
    }

	publications {
		mavenJava(MavenPublication) {
			from components.java
			pom {
				description = "eLink EMS Client module"
				licenses {
					license {
						name = "Commercial License"
						url = "http://eactive.co.kr"
					}
				}
			}
		}
	}
}


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

artifacts {
    archives sourcesJar
}

configurations.all {
    resolutionStrategy {
        // 동적 버전 탐색을 10분 캐시
        cacheDynamicVersionsFor 10, 'minutes'
        // 변하는 모듈(Changing Module)을 캐시하지 않음
        cacheChangingModulesFor 0, 'seconds'
    }
}

task settingEclipseEncoding {
    if (project.file('.settings').exists()) {
        File f = file('.settings/org.eclipse.core.resources.prefs')
        f.write('eclipse.preferences.version=1\n')
        f.append('encoding/<project>=utf-8')
    }
}

//eclipseJdt.finalizedBy settingEclipseEncoding

eclipse {
    synchronizationTasks settingEclipseEncoding
}
