Compare commits

..

12 commits

89 changed files with 891 additions and 290 deletions

View file

@ -1,22 +1,24 @@
plugins {
id "de.marcphilipp.nexus-publish" version "0.4.0"
id "io.codearte.nexus-staging" version "0.21.1"
id 'maven-publish'
id 'signing'
id "io.github.gradle-nexus.publish-plugin" version "2.0.0-rc-1"
}
wrapper {
gradleVersion = "${project.property('gradle.wrapper.version')}"
gradleVersion = libs.versions.gradle.get()
distributionType = Wrapper.DistributionType.ALL
}
ext {
user = 'jprante'
user = 'joerg'
name = 'groovy-extensions'
description = 'Groovy extensions'
inceptionYear = '2021'
url = 'https://github.com/' + user + '/' + name
scmUrl = 'https://github.com/' + user + '/' + name
scmConnection = 'scm:git:git://github.com/' + user + '/' + name + '.git'
scmDeveloperConnection = 'scm:git:ssh://git@github.com:' + user + '/' + name + '.git'
url = 'https://xbib.org/' + user + '/' + name
scmUrl = 'https://xbib.org/' + user + '/' + name
scmConnection = 'scm:git:git://xbib.org/' + user + '/' + name + '.git'
scmDeveloperConnection = 'scm:git:ssh://forgejo@xbib.org:' + user + '/' + name + '.git'
issueManagementSystem = 'Github'
issueManagementUrl = ext.scmUrl + '/issues'
licenseName = 'The Apache License, Version 2.0'
@ -24,11 +26,9 @@ ext {
}
subprojects {
apply plugin: 'java-library'
apply from: rootProject.file('gradle/ide/idea.gradle')
apply from: rootProject.file('gradle/compile/java.gradle')
apply from: rootProject.file('gradle/test/junit5.gradle')
apply from: rootProject.file('gradle/repositories/maven.gradle')
apply from: rootProject.file('gradle/publishing/publication.gradle')
apply from: rootProject.file('gradle/publish/maven.gradle')
}
apply from: rootProject.file('gradle/publishing/sonatype.gradle')
apply from: rootProject.file('gradle/publish/sonatype.gradle')
apply from: rootProject.file('gradle/publish/forgejo.gradle')

View file

@ -1,14 +1,3 @@
group = org.xbib.groovy
name = groovy-extensions
version = 4.0.2.0
org.gradle.warning.mode = ALL
groovy.version = 4.0.2
gradle.wrapper.version = 7.3.2
files.version = 3.0.0
ftp.version = 2.6.0
mail.version = 1.6.2
sshd.version = 2.6.0.0
junit4.version = 4.13.2
jgit.version = 5.13.0.202109080827-r
spock.version = 2.2-M1-groovy-4.0
version = 5.0.0

View file

@ -0,0 +1,32 @@
apply plugin: 'groovy'
dependencies {
implementation libs.groovy.core
testImplementation libs.groovy.core
}
compileGroovy {
groovyOptions.configurationScript = rootProject.file('gradle/compile/groovyc.groovy')
}
compileTestGroovy {
}
tasks.withType(GroovyCompile) {
options.compilerArgs
if (!options.compilerArgs.contains("-processor")) {
options.compilerArgs << '-proc:none'
}
}
task groovydocJar(type: Jar, dependsOn: 'groovydoc') {
from groovydoc.destinationDir
archiveClassifier.set('javadoc')
}
sourceSets {
main {
java { srcDirs = [] }
groovy { srcDirs += ['src/main/java'] }
}
}

View file

@ -0,0 +1,27 @@
apply plugin: 'groovy'
dependencies {
implementation libs.groovy.core
testImplementation libs.groovy.core
}
compileGroovy {
}
compileTestGroovy {
}
tasks.withType(GroovyCompile) {
if (!options.compilerArgs.contains("-processor")) {
options.compilerArgs.add('-proc:none')
}
}
task groovydocJar(type: Jar, dependsOn: 'groovydoc') {
from groovydoc.destinationDir
archiveClassifier.set('groovydoc')
}
artifacts {
archives groovydocJar
}

View file

@ -1,17 +1,16 @@
apply plugin: 'groovy'
dependencies {
implementation "org.apache.groovy:groovy:${project.property('groovy.version')}"
implementation libs.groovy.core
testImplementation libs.groovy.core
}
compileGroovy {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
groovyOptions.configurationScript = rootProject.file('gradle/compile/groovyc.groovy')
}
compileTestGroovy {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
groovyOptions.configurationScript = rootProject.file('gradle/compile/groovyc.groovy')
}
tasks.withType(GroovyCompile) {
@ -21,7 +20,20 @@ tasks.withType(GroovyCompile) {
}
}
task groovydocJar(type: Jar, dependsOn: 'groovydoc') {
task groovydocJar(type: Jar) {
dependsOn groovydoc
from groovydoc.destinationDir
archiveClassifier.set('javadoc')
archiveClassifier.set('groovydoc')
}
tasks.assemble.dependsOn(tasks.groovydocJar)
artifacts {
archives groovydocJar
}
sourceSets {
main {
java { srcDirs = [] }
groovy { srcDirs += ['src/main/java'] }
}
}

View file

@ -0,0 +1,7 @@
import groovy.transform.TypeChecked
import groovy.transform.CompileStatic
withConfig(configuration) {
ast(TypeChecked)
ast(CompileStatic)
}

View file

@ -2,42 +2,34 @@
apply plugin: 'java-library'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
modularity.inferModulePath.set(true)
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withSourcesJar()
withJavadocJar()
}
jar {
manifest {
attributes('Implementation-Version': project.version)
attributes('X-Java-Compiler-Version': JavaLanguageVersion.of(21).toString())
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier 'javadoc'
}
artifacts {
archives sourcesJar, javadocJar
}
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:all,-fallthrough'
options.fork = true
options.forkOptions.jvmArgs += [
'-Duser.language=en',
'-Duser.country=US',
]
options.compilerArgs += [
'-Xlint:all'
]
options.encoding = 'UTF-8'
}
javadoc {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.encoding = 'UTF-8'
}

View file

@ -0,0 +1,16 @@
if (project.hasProperty('forgeJoToken')) {
publishing {
repositories {
maven {
url 'https://xbib.org/api/packages/joerg/maven'
credentials(HttpHeaderCredentials) {
name = "Authorization"
value = "token ${project.property('forgeJoToken')}"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
}

27
gradle/publish/ivy.gradle Normal file
View file

@ -0,0 +1,27 @@
apply plugin: 'ivy-publish'
publishing {
repositories {
ivy {
url = "https://xbib.org/repo"
}
}
publications {
ivy(IvyPublication) {
from components.java
descriptor {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
author {
name = 'Jörg Prante'
url = 'http://example.com/users/jane'
}
descriptor.description {
text = rootProject.ext.description
}
}
}
}
}

View file

@ -1,13 +1,10 @@
apply plugin: "de.marcphilipp.nexus-publish"
publishing {
publications {
mavenJava(MavenPublication) {
"${project.name}"(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom {
artifactId = project.name
name = project.name
description = rootProject.ext.description
url = rootProject.ext.url
@ -49,18 +46,6 @@ publishing {
if (project.hasProperty("signing.keyId")) {
apply plugin: 'signing'
signing {
sign publishing.publications.mavenJava
}
}
if (project.hasProperty("ossrhUsername")) {
nexusPublishing {
repositories {
sonatype {
username = project.property('ossrhUsername')
password = project.property('ossrhPassword')
packageGroup = "org.xbib"
}
}
sign publishing.publications."${project.name}"
}
}

View file

@ -0,0 +1,11 @@
if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
nexusPublishing {
repositories {
sonatype {
username = project.property('ossrhUsername')
password = project.property('ossrhPassword')
packageGroup = "org.xbib"
}
}
}
}

View file

@ -1,11 +0,0 @@
if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
apply plugin: 'io.codearte.nexus-staging'
nexusStaging {
username = project.property('ossrhUsername')
password = project.property('ossrhPassword')
packageGroup = "org.xbib"
}
}

View file

@ -1,17 +1,14 @@
def junitVersion = project.hasProperty('junit.version')?project.property('junit.version'):'5.8.0'
def hamcrestVersion = project.hasProperty('hamcrest.version')?project.property('hamcrest.version'):'2.2'
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
testImplementation "org.hamcrest:hamcrest-library:${hamcrestVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
testImplementation libs.junit.jupiter.api
testImplementation libs.junit.jupiter.params
testImplementation libs.hamcrest
testRuntimeOnly libs.junit.jupiter.engine
}
test {
useJUnitPlatform()
failFast = false
systemProperty 'java.util.logging.config.file', 'src/test/resources/logging.properties'
testLogging {
events 'STARTED', 'PASSED', 'FAILED', 'SKIPPED'
}

Binary file not shown.

View file

@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

41
gradlew vendored
View file

@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@ -80,13 +80,11 @@ do
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
@ -205,6 +214,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

15
gradlew.bat vendored
View file

@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal

View file

@ -1,17 +1,6 @@
= Groovy crypt library
image:https://api.travis-ci.org/xbib/groovy-crypt.svg[title="Build status", link="https://travis-ci.org/xbib/groovy-crypt/"]
image:https://maven-badges.herokuapp.com/maven-central/org.xbib.groovy/groovy-crypt/badge.svg[title="Maven Central", link="http://search.maven.org/#search%7Cga%7C1%7Cxbib%20groovy-crypt"]
image:https://img.shields.io/badge/License-Apache%202.0-blue.svg[title="Apache License 2.0", link="https://opensource.org/licenses/Apache-2.0"]
image:https://img.shields.io/twitter/url/https/twitter.com/xbib.svg?style=social&label=Follow%20%40xbib[title="Twitter", link="https://twitter.com/xbib"]
image:https://sonarqube.com/api/badges/gate?key=org.xbib.groovy:groovy-crypt[title="Quality Gate", link="https://sonarqube.com/dashboard/index?id=org.xbib.groovy%3Agroovy-crypt"]
image:https://sonarqube.com/api/badges/measure?key=org.xbib.groovy:groovy-crypt&metric=coverage[title="Coverage", link="https://sonarqube.com/dashboard/index?id=org.xbib.groovy%3Agroovy-crypt"]
image:https://sonarqube.com/api/badges/measure?key=org.xbib.groovy:groovy-crypt&metric=vulnerabilities[title="Vulnerabilities", link="https://sonarqube.com/dashboard/index?id=org.xbib.groovy%3Agroovy-crypt"]
image:https://sonarqube.com/api/badges/measure?key=org.xbib.groovy:groovy-crypt&metric=bugs[title="Bugs", link="https://sonarqube.com/dashboard/index?id=org.xbib.groovy%3Agroovy-crypt"]
image:https://sonarqube.com/api/badges/measure?key=org.xbib.groovy:groovy-crypt&metric=sqale_debt_ratio[title="Technical debt ratio", link="https://sonarqube.com/dashboard/index?id=org.xbib.groovy%3Agroovy-crypt"]
This Groovy crypt implementation of the `crypt(3)` function provided in the GNU C library (glibc)
was derived from crypt4j by Carl Harris https://github.com/soulwing/crypt4j

View file

@ -0,0 +1 @@
version = 5.0.0

View file

@ -1,5 +1,7 @@
package org.xbib.groovy.crypt
import org.xbib.groovy.crypt.random.RandomUtil
import javax.crypto.Mac
import javax.crypto.SecretKeyFactory
import javax.crypto.spec.PBEKeySpec
@ -9,7 +11,6 @@ import java.nio.ByteOrder
import java.nio.charset.StandardCharsets
import java.security.MessageDigest
import java.security.NoSuchAlgorithmException
import java.security.SecureRandom
/**
* A utility class for invoking encryption methods and returning LDAP password string,
@ -17,8 +18,6 @@ import java.security.SecureRandom
*/
class CryptUtil {
private static final Random random = new SecureRandom()
static String hexDigest(String plainText, String algo, String prefix) throws NoSuchAlgorithmException {
if (plainText == null) {
return null
@ -152,13 +151,7 @@ class CryptUtil {
}
static String randomHexString(int length) {
randomBytes(length).encodeHex()
}
static byte[] randomBytes(int length) {
byte[] b = new byte[length]
random.nextBytes(b)
b
RandomUtil.randomBytes(length).encodeHex()
}
static ByteBuffer htonl(int value) {

View file

@ -102,10 +102,12 @@ class MersenneTwisterRandom extends Random {
}
private static int[] convertBytesToInts(byte[] bytes) {
if (bytes.length % 4 != 0) {
int l = bytes.length
if (l % 4 != 0) {
throw new IllegalArgumentException("number of input bytes must be a multiple of 4")
}
int[] ints = new int[bytes.length / 4]
int size = l.intdiv(4)
int[] ints = new int[size]
for (int i = 0; i < ints.length; i++) {
ints[i] = convertBytesToInt(bytes, i * 4)
}

View file

@ -11,4 +11,10 @@ class RandomUtil {
secureRandom.nextBytes(b)
b.encodeHex().toString()
}
static byte[] randomBytes(int length) {
byte[] b = new byte[length]
secureRandom.nextBytes(b)
b
}
}

202
groovy-ftp/LICENSE.txt Normal file
View file

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -1,5 +1,5 @@
apply from: rootProject.file('gradle/compile/groovy.gradle')
dependencies {
api "org.xbib:ftp-fs:${project.property('ftp.version')}"
api libs.ftp.fs
}

View file

@ -0,0 +1 @@
version = 5.0.0

202
groovy-ftps/LICENSE.txt Normal file
View file

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -1,5 +1,5 @@
apply from: rootProject.file('gradle/compile/groovy.gradle')
dependencies {
api "org.xbib:ftp-fs:${project.property('ftp.version')}"
api libs.ftp.fs
}

View file

@ -0,0 +1 @@
version = 5.0.0

View file

@ -0,0 +1,2 @@
apply from: rootProject.file('gradle/compile/groovy-dynamic-tests.gradle')

View file

@ -1,4 +1,4 @@
package org.xbib.groovy.git.internal;
package org.xbib.groovy.git.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@ -9,7 +9,7 @@ import org.codehaus.groovy.transform.GroovyASTTransformationClass;
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
@GroovyASTTransformationClass("org.xbib.groovy.git.internal.AnnotateAtRuntimeASTTransformation")
@GroovyASTTransformationClass(classes = {AnnotateAtRuntimeASTTransformation.class})
public @interface AnnotateAtRuntime {
String[] annotations() default {};
}

View file

@ -0,0 +1,32 @@
package org.xbib.groovy.git.annotations;
import java.util.List;
import org.codehaus.groovy.ast.ASTNode;
import org.codehaus.groovy.ast.AnnotatedNode;
import org.codehaus.groovy.ast.AnnotationNode;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.transform.AbstractASTTransformation;
import org.codehaus.groovy.transform.GroovyASTTransformation;
@GroovyASTTransformation
public final class AnnotateAtRuntimeASTTransformation extends AbstractASTTransformation {
@Override
public void visit(ASTNode[] nodes, SourceUnit source) {
AnnotationNode annotation = (AnnotationNode) nodes[0];
AnnotatedNode parent = (AnnotatedNode) nodes[1];
ClassNode clazz = (ClassNode) parent;
List<String> annotations = getMemberStringList(annotation, "annotations");
for (String name : annotations) {
// !!! UGLY HACK !!!
// Groovy won't think the class is an annotation when creating a ClassNode just based on the name.
// Instead, we create a node based on an interface and then overwrite the name to get the interface
// we actually want.
ClassNode base = new ClassNode(FunctionalInterface.class);
base.setName(name);
clazz.addAnnotation(new AnnotationNode(base));
}
}
}

View file

@ -0,0 +1,7 @@
package org.xbib.groovy.git.annotations;
@FunctionalInterface
@AnnotateAtRuntime(annotations = "org.gradle.api.HasImplicitReceiver")
public interface Configurable<T> {
void configure(T t);
}

View file

@ -1,9 +1,7 @@
package org.xbib.groovy.git.internal
package org.xbib.groovy.git.annotations;
import java.util.concurrent.Callable
import org.xbib.groovy.git.Configurable
class OpSyntax {
static def noArgOperation(Class<Callable> opClass, Object[] classArgs) {
def op = opClass.newInstance(classArgs)
@ -14,7 +12,7 @@ class OpSyntax {
def op = opClass.newInstance(classArgs)
args.forEach { key, value ->
op[key] = value
op[key as String] = value
}
return op.call()

View file

@ -1,4 +1,4 @@
package org.xbib.groovy.git.internal;
package org.xbib.groovy.git.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View file

@ -1,4 +1,4 @@
package org.xbib.groovy.git.internal;
package org.xbib.groovy.git.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@ -10,7 +10,7 @@ import org.codehaus.groovy.transform.GroovyASTTransformationClass;
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
@GroovyASTTransformationClass("org.xbib.groovy.git.internal.WithOperationsASTTransformation")
@GroovyASTTransformationClass(classes = {WithOperationsASTTransformation.class})
public @interface WithOperations {
Class<? extends Callable<?>>[] staticOperations() default {};

View file

@ -1,4 +1,4 @@
package org.xbib.groovy.git.internal;
package org.xbib.groovy.git.annotations;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
@ -9,12 +9,12 @@ import java.util.List;
import java.util.Map;
import groovy.lang.Closure;
import org.xbib.groovy.git.Configurable;
import org.codehaus.groovy.ast.ASTNode;
import org.codehaus.groovy.ast.AnnotatedNode;
import org.codehaus.groovy.ast.AnnotationNode;
import org.codehaus.groovy.ast.ClassHelper;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.FieldNode;
import org.codehaus.groovy.ast.GenericsType;
import org.codehaus.groovy.ast.MethodNode;
import org.codehaus.groovy.ast.Parameter;
@ -163,14 +163,15 @@ public class WithOperationsASTTransformation extends AbstractASTTransformation {
return Arrays.stream(types)
.map(this::classFromType)
.map(GenericsType::new)
.toArray(GenericsType[]::new);
.toArray(size -> new GenericsType[size]);
}
public List<Expression> opConstructorParms(ClassNode targetClass, boolean isStatic) {
if (isStatic) {
return Collections.emptyList();
} else {
return Collections.singletonList(new FieldExpression(targetClass.getField("repository")));
FieldNode repo = targetClass.getField("repository");
return Arrays.asList(new FieldExpression(repo));
}
}

View file

@ -1,8 +1,8 @@
apply from: rootProject.file('gradle/compile/groovy.gradle')
apply from: rootProject.file('gradle/compile/groovy-dynamic-tests.gradle')
dependencies {
api "org.eclipse.jgit:org.eclipse.jgit:${project.property('jgit.version')}"
testImplementation "org.apache.groovy:groovy:${project.property('groovy.version')}"
testImplementation "org.spockframework:spock-core:${project.property('spock.version')}"
testImplementation "org.spockframework:spock-junit4:${project.property('spock.version')}"
api project(':groovy-git-annotations')
api libs.jgit
testImplementation libs.spock.core
testImplementation libs.spock.junit4
}

View file

@ -0,0 +1 @@
version = 5.0.0

View file

@ -1,9 +0,0 @@
package org.xbib.groovy.git
import org.xbib.groovy.git.internal.AnnotateAtRuntime
@FunctionalInterface
@AnnotateAtRuntime(annotations = "org.gradle.api.HasImplicitReceiver")
interface Configurable<T> {
void configure(T t)
}

View file

@ -1,6 +1,6 @@
package org.xbib.groovy.git
import org.xbib.groovy.git.internal.WithOperations
import org.xbib.groovy.git.annotations.WithOperations
import org.xbib.groovy.git.operation.AddOp
import org.xbib.groovy.git.operation.ApplyOp
import org.xbib.groovy.git.operation.CheckoutOp

View file

@ -9,35 +9,35 @@ import groovy.transform.ToString
@EqualsAndHashCode
@ToString(includeNames=true)
class Status {
final Changes staged
final Changes unstaged
final Set<String> conflicts
Changes staged
Changes unstaged
Set<String> conflicts
Status(Map args = [:]) {
def invalidArgs = args.keySet() - ['staged', 'unstaged', 'conflicts']
if (invalidArgs) {
throw new IllegalArgumentException("Following keys are not supported: ${invalidArgs}")
}
this.staged = 'staged' in args ? new Changes(args.staged) : new Changes()
this.unstaged = 'unstaged' in args ? new Changes(args.unstaged) : new Changes()
this.conflicts = 'conflicts' in args ? args.conflicts : []
this.staged = 'staged' in args ? new Changes(args['staged'] as Map) : new Changes()
this.unstaged = 'unstaged' in args ? new Changes(args['unstaged'] as Map) : new Changes()
this.conflicts = 'conflicts' in args ? args['conflicts'] as Set<String> : [] as Set<String>
}
@EqualsAndHashCode
@ToString(includeNames=true)
class Changes {
final Set<String> added
final Set<String> modified
final Set<String> removed
Set<String> added
Set<String> modified
Set<String> removed
Changes(Map args = [:]) {
def invalidArgs = args.keySet() - ['added', 'modified', 'removed']
if (invalidArgs) {
throw new IllegalArgumentException("Following keys are not supported: ${invalidArgs}")
}
this.added = 'added' in args ? args.added : []
this.modified = 'modified' in args ? args.modified : []
this.removed = 'removed' in args ? args.removed : []
this.added = 'added' in args ? args['added'] as Set<String> : [] as Set<String>
this.modified = 'modified' in args ? args['modified'] as Set<String> : [] as Set<String>
this.removed = 'removed' in args ? args['removed'] as Set<String> : [] as Set<String>
}
/**

View file

@ -52,6 +52,6 @@ class AuthConfig {
* @throws IllegalArgumentException if force is set to an invalid option
*/
static AuthConfig fromSystem() {
return fromMap(System.properties, System.env)
return fromMap(System.properties as Map, System.getenv() as Map)
}
}

View file

@ -1,34 +0,0 @@
package org.xbib.groovy.git.internal;
import java.util.List;
import org.codehaus.groovy.ast.ASTNode;
import org.codehaus.groovy.ast.AnnotatedNode;
import org.codehaus.groovy.ast.AnnotationNode;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.transform.AbstractASTTransformation;
import org.codehaus.groovy.transform.GroovyASTTransformation;
@GroovyASTTransformation
public final class AnnotateAtRuntimeASTTransformation extends AbstractASTTransformation {
@Override
public void visit(ASTNode[] nodes, SourceUnit source) {
AnnotationNode annotation = (AnnotationNode) nodes[0];
AnnotatedNode parent = (AnnotatedNode) nodes[1];
ClassNode clazz = (ClassNode) parent;
List<String> annotations = getMemberStringList(annotation, "annotations");
for (String name : annotations) {
// !!! UGLY HACK !!!
// Groovy won't think the class is an annotation when creating a ClassNode just based on the name.
// Instead, we create a node based on an interface and then overwrite the name to get the interface
// we actually want.
ClassNode base = new ClassNode(FunctionalInterface.class);
base.setName(name);
clazz.addAnnotation(new AnnotationNode(base));
}
}
}

View file

@ -1,9 +1,10 @@
package org.xbib.groovy.git.operation
import org.xbib.groovy.git.annotations.Operation
import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.eclipse.jgit.api.AddCommand
/**

View file

@ -3,7 +3,7 @@ package org.xbib.groovy.git.operation
import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.util.CoercionUtil
import org.eclipse.jgit.api.ApplyCommand

View file

@ -5,7 +5,7 @@ import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode
import org.eclipse.jgit.lib.Ref
import org.xbib.groovy.git.Branch
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.xbib.groovy.git.util.GitUtil

View file

@ -4,7 +4,7 @@ import java.util.concurrent.Callable
import org.xbib.groovy.git.Branch
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.xbib.groovy.git.util.GitUtil
import org.eclipse.jgit.api.CreateBranchCommand

View file

@ -4,7 +4,7 @@ import java.util.concurrent.Callable
import org.xbib.groovy.git.Branch
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.xbib.groovy.git.util.GitUtil
import org.eclipse.jgit.api.ListBranchCommand

View file

@ -3,7 +3,7 @@ package org.xbib.groovy.git.operation
import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.eclipse.jgit.api.DeleteBranchCommand

View file

@ -5,7 +5,7 @@ import java.util.concurrent.Callable
import org.xbib.groovy.git.Branch
import org.xbib.groovy.git.BranchStatus
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.eclipse.jgit.lib.BranchTrackingStatus

View file

@ -3,7 +3,7 @@ package org.xbib.groovy.git.operation
import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.eclipse.jgit.api.CheckoutCommand

View file

@ -3,7 +3,7 @@ package org.xbib.groovy.git.operation
import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.eclipse.jgit.api.CleanCommand
/**

View file

@ -7,7 +7,7 @@ import java.util.concurrent.Callable
import org.xbib.groovy.git.Credentials
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.auth.TransportOpUtil
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.util.CoercionUtil
import org.eclipse.jgit.api.CloneCommand

View file

@ -5,7 +5,7 @@ import java.util.concurrent.Callable
import org.xbib.groovy.git.Commit
import org.xbib.groovy.git.Person
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.util.GitUtil
import org.eclipse.jgit.api.CommitCommand
import org.eclipse.jgit.lib.PersonIdent

View file

@ -3,7 +3,7 @@ package org.xbib.groovy.git.operation
import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.eclipse.jgit.api.DescribeCommand

View file

@ -4,7 +4,7 @@ import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.auth.TransportOpUtil
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.eclipse.jgit.api.FetchCommand
import org.eclipse.jgit.transport.RefSpec
import org.eclipse.jgit.transport.TagOpt
@ -53,7 +53,7 @@ class FetchOp implements Callable<Void> {
TransportOpUtil.configure(cmd, repo.credentials)
if (remote) { cmd.remote = remote }
cmd.refSpecs = refSpecs.collect {
new RefSpec(it)
new RefSpec(it as String)
}
cmd.removeDeletedRefs = prune
cmd.tagOpt = tagMode.jgit

View file

@ -3,7 +3,7 @@ package org.xbib.groovy.git.operation
import org.xbib.groovy.git.Git
import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.util.CoercionUtil
import org.eclipse.jgit.api.InitCommand

View file

@ -3,7 +3,7 @@ package org.xbib.groovy.git.operation
import java.util.concurrent.Callable
import org.xbib.groovy.git.Commit
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.xbib.groovy.git.util.GitUtil
import org.eclipse.jgit.api.LogCommand

View file

@ -4,7 +4,7 @@ import java.util.concurrent.Callable
import org.xbib.groovy.git.Ref
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.auth.TransportOpUtil
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.eclipse.jgit.api.LsRemoteCommand
import org.eclipse.jgit.lib.ObjectId

View file

@ -1,8 +1,10 @@
package org.xbib.groovy.git.operation
import org.eclipse.jgit.lib.Ref
import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.xbib.groovy.git.util.GitUtil
import org.eclipse.jgit.api.MergeCommand
@ -60,7 +62,7 @@ class MergeOp implements Callable<Void> {
* we want to preserve ref name in merge commit msg. if it's a ref, don't
* resolve down to commit id
*/
def ref = repo.jgit.repository.findRef(head)
Ref ref = repo.jgit.repository.findRef(head as String)
if (ref == null) {
def revstr = new ResolveService(repo).toRevisionString(head)
cmd.include(GitUtil.resolveObject(repo, revstr))

View file

@ -4,7 +4,7 @@ import org.xbib.groovy.git.Git
import java.util.concurrent.Callable
import org.xbib.groovy.git.Credentials
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.util.CoercionUtil
import org.eclipse.jgit.storage.file.FileRepositoryBuilder

View file

@ -4,7 +4,7 @@ import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.auth.TransportOpUtil
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.eclipse.jgit.api.PullCommand
import org.eclipse.jgit.api.PullResult

View file

@ -1,10 +1,12 @@
package org.xbib.groovy.git.operation
import org.eclipse.jgit.lib.Ref
import java.util.concurrent.Callable
import org.xbib.groovy.git.PushException
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.auth.TransportOpUtil
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.eclipse.jgit.api.PushCommand
import org.eclipse.jgit.transport.RemoteRefUpdate
@ -63,7 +65,11 @@ class PushOp implements Callable<Void> {
cmd.remote = remote
}
refsOrSpecs.each {
cmd.add(it)
if (it instanceof Ref) {
cmd.add(it as Ref)
} else if (it instanceof String) {
cmd.add(it as String)
}
}
if (all) {
cmd.setPushAll()

View file

@ -3,7 +3,7 @@ package org.xbib.groovy.git.operation
import java.util.concurrent.Callable
import org.xbib.groovy.git.Remote
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.util.GitUtil
import org.eclipse.jgit.lib.Config
import org.eclipse.jgit.transport.RefSpec
@ -60,10 +60,10 @@ class RemoteAddOp implements Callable<Remote> {
throw new IllegalStateException("remote $name already exists")
}
def toUri = {
url -> new URIish(url)
url -> new URIish(url as String)
}
def toRefSpec = {
spec -> new RefSpec(spec)
spec -> new RefSpec(spec as String)
}
RemoteConfig remote = new RemoteConfig(config, name)
if (url) {
@ -72,7 +72,7 @@ class RemoteAddOp implements Callable<Remote> {
if (pushUrl) {
remote.addPushURI(toUri(pushUrl))
}
remote.fetchRefSpecs = (fetchRefSpecs ?: ["+refs/heads/*:refs/remotes/$name/*"]).collect(toRefSpec)
remote.fetchRefSpecs = (fetchRefSpecs ?: ["+refs/heads/*:refs/remotes/$name/*"]).collect(toRefSpec) as List<RefSpec>
remote.pushRefSpecs = pushRefSpecs.collect(toRefSpec)
remote.mirror = mirror
remote.update(config)

View file

@ -4,7 +4,7 @@ import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.Remote
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.util.GitUtil
import org.eclipse.jgit.transport.RemoteConfig

View file

@ -3,7 +3,7 @@ package org.xbib.groovy.git.operation
import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.eclipse.jgit.api.ResetCommand

View file

@ -4,7 +4,7 @@ import java.util.concurrent.Callable
import org.xbib.groovy.git.Commit
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.xbib.groovy.git.util.GitUtil
import org.eclipse.jgit.api.RevertCommand

View file

@ -3,7 +3,7 @@ package org.xbib.groovy.git.operation
import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.eclipse.jgit.api.RmCommand
/**

View file

@ -1,10 +1,12 @@
package org.xbib.groovy.git.operation
import org.eclipse.jgit.lib.AnyObjectId
import java.util.concurrent.Callable
import org.xbib.groovy.git.CommitDiff
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.xbib.groovy.git.util.GitUtil
import org.eclipse.jgit.diff.DiffEntry
@ -44,8 +46,8 @@ class ShowOp implements Callable<CommitDiff> {
walk.recursive = true
if (parentId) {
walk.addTree(parentId.tree)
walk.addTree(commitId.tree)
walk.addTree(parentId['tree'] as AnyObjectId)
walk.addTree(commitId['tree'] as AnyObjectId)
List initialEntries = DiffEntry.scan(walk)
RenameDetector detector = new RenameDetector(repo.jgit.repository)
detector.addAll(initialEntries)
@ -61,7 +63,7 @@ class ShowOp implements Callable<CommitDiff> {
renamed: entriesByType[ChangeType.RENAME].collect { it.newPath }
)
} else {
walk.addTree(commitId.tree)
walk.addTree(commitId['tree'] as AnyObjectId)
def added = []
while (walk.next()) {
added << walk.pathString

View file

@ -4,7 +4,7 @@ import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.Status
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.util.GitUtil
import org.eclipse.jgit.api.StatusCommand

View file

@ -4,7 +4,7 @@ import java.util.concurrent.Callable
import org.xbib.groovy.git.Person
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.Tag
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.xbib.groovy.git.util.GitUtil
import org.eclipse.jgit.api.TagCommand

View file

@ -3,7 +3,7 @@ package org.xbib.groovy.git.operation
import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.Tag
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.util.GitUtil
import org.eclipse.jgit.api.ListTagCommand

View file

@ -2,7 +2,7 @@ package org.xbib.groovy.git.operation
import java.util.concurrent.Callable
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.Operation
import org.xbib.groovy.git.annotations.Operation
import org.xbib.groovy.git.service.ResolveService
import org.eclipse.jgit.api.DeleteTagCommand

View file

@ -2,7 +2,7 @@ package org.xbib.groovy.git.service
import org.xbib.groovy.git.Branch
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.WithOperations
import org.xbib.groovy.git.annotations.WithOperations
import org.xbib.groovy.git.operation.BranchAddOp
import org.xbib.groovy.git.operation.BranchChangeOp
import org.xbib.groovy.git.operation.BranchListOp

View file

@ -1,7 +1,7 @@
package org.xbib.groovy.git.service
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.WithOperations
import org.xbib.groovy.git.annotations.WithOperations
import org.xbib.groovy.git.operation.RemoteAddOp
import org.xbib.groovy.git.operation.RemoteListOp

View file

@ -138,11 +138,11 @@ class ResolveService {
*/
Tag toTag(Object object) {
if (object == null) {
return object
return object as Tag
} else if (object instanceof Tag) {
return object
} else if (object instanceof String || object instanceof GString) {
GitUtil.resolveTag(repository, object)
GitUtil.resolveTag(repository, object as String)
} else {
throwIllegalArgument(object)
}

View file

@ -1,7 +1,7 @@
package org.xbib.groovy.git.service
import org.xbib.groovy.git.Repository
import org.xbib.groovy.git.internal.WithOperations
import org.xbib.groovy.git.annotations.WithOperations
import org.xbib.groovy.git.operation.TagAddOp
import org.xbib.groovy.git.operation.TagListOp
import org.xbib.groovy.git.operation.TagRemoveOp

View file

@ -68,7 +68,7 @@ class GitUtil {
RevCommit rev = walk.parseCommit(id)
return rev.parents.collect {
walk.parseCommit(it)
}
} as Set<ObjectId>
}
/**
@ -126,7 +126,7 @@ class GitUtil {
* @return the resolved tag
*/
static Tag resolveTag(Repository repo, String name) {
Ref ref = repo.jgit.repository.getRef(name)
Ref ref = repo.jgit.repository.getRefDatabase().findRef(name)
return resolveTag(repo, ref)
}
@ -144,7 +144,7 @@ class GitUtil {
RevTag rev = walk.parseTag(ref.objectId)
RevObject target = walk.peel(rev)
walk.parseBody(rev.object)
props.commit = convertCommit(repo, target)
props.commit = convertCommit(repo, target as RevCommit)
PersonIdent tagger = rev.taggerIdent
props.tagger = new Person(tagger.name, tagger.emailAddress)
props.fullMessage = rev.fullMessage
@ -185,7 +185,7 @@ class GitUtil {
}
Map props = [:]
props.fullName = ref.name
String shortName = org.eclipse.jgit.lib.Repository.shortenRefName(props.fullName)
String shortName = org.eclipse.jgit.lib.Repository.shortenRefName(props['fullName'] as String)
Config config = repo.jgit.repository.config
BranchConfig branchConfig = new BranchConfig(config, shortName)
if (branchConfig.trackingBranch) {

View file

@ -1,6 +1 @@
apply from: rootProject.file('gradle/compile/groovy.gradle')
dependencies {
testImplementation "org.apache.groovy:groovy:${project.property('groovy.version')}"
testImplementation "junit:junit:${project.property('junit4.version')}"
}
apply from: rootProject.file('gradle/compile/groovy-dynamic-tests.gradle')

View file

@ -0,0 +1 @@
version = 5.0.0

View file

@ -384,6 +384,9 @@ public class LDAP {
}
public static String escapeValue(String filter) {
if (filter == null) {
return null;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < filter.length(); i++) {
switch (filter.charAt(i)) {
@ -423,5 +426,4 @@ public class LDAP {
}
return sb.toString();
}
}

View file

@ -1,8 +1,7 @@
package org.xbib.groovy.ldap;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class JavaSearchTest {

View file

@ -1,5 +1,5 @@
apply from: rootProject.file('gradle/compile/groovy.gradle')
dependencies {
api "com.sun.mail:javax.mail:${project.property('mail.version')}"
api libs.mail
}

View file

@ -0,0 +1 @@
version = 5.0.0

View file

@ -1,5 +1,6 @@
package org.xbib.groovy.smtp;
import java.util.List;
import javax.mail.Address;
import javax.mail.Authenticator;
import javax.mail.Message;
@ -27,22 +28,25 @@ public class SMTP {
private final String password;
private SMTP(String url, String username, String password) {
private final boolean debug;
private SMTP(String url, String username, String password, boolean debug) {
this.url = url;
this.username = username;
this.password = password;
this.debug = debug;
}
public static SMTP newInstance() {
return new SMTP(DEFAULT_URL, null, null);
return new SMTP(DEFAULT_URL, null, null, false);
}
public static SMTP newInstance(String url) {
return new SMTP(url, null, null);
return new SMTP(url, null, null, false);
}
public static SMTP newInstance(String url, String username, String password) {
return new SMTP(url, username, password);
public static SMTP newInstance(String url, String username, String password, boolean debug) {
return new SMTP(url, username, password, debug);
}
public String getURL() {
@ -50,10 +54,67 @@ public class SMTP {
}
public void send(String subject, String from, String to, String text) throws Exception {
Address[] toAddr = { new InternetAddress(to) };
if (from == null) {
return;
}
if (to == null) {
return;
}
String[] s = to.split(",");
Address[] toAddr = new Address[s.length];
for (int i = 0; i < s.length; i++) {
toAddr[i] = new InternetAddress(s[i]);
}
send(subject, new InternetAddress(from), null, toAddr, null, null, text);
}
public void send(String subject, String from, List<String> to, String text) throws Exception {
if (from == null) {
return;
}
if (to == null) {
return;
}
if (to.size() > 0) {
Address[] toAddr = new Address[to.size()];
for (int i = 0; i < to.size(); i++) {
toAddr[i] = new InternetAddress(to.get(i));
}
send(subject, new InternetAddress(from), null, toAddr, null, null, text);
}
}
public void send(String subject, String from, List<String> to, List<String> cc, List<String> bcc, String text) throws Exception {
if (from == null) {
return;
}
if (to == null) {
return;
}
Address[] toAddr = null;
if (to.size() > 0) {
toAddr = new Address[to.size()];
for (int i = 0; i < to.size(); i++) {
toAddr[i] = new InternetAddress(to.get(i));
}
}
Address[] ccAddr = null;
if (cc != null && cc.size() > 0) {
ccAddr = new Address[cc.size()];
for (int i = 0; i < cc.size(); i++) {
ccAddr[i] = new InternetAddress(cc.get(i));
}
}
Address[] bccAddr = null;
if (bcc != null && bcc.size() > 0) {
bccAddr = new Address[bcc.size()];
for (int i = 0; i < bcc.size(); i++) {
bccAddr[i] = new InternetAddress(bcc.get(i));
}
}
send(subject, new InternetAddress(from), null, toAddr, ccAddr, bccAddr, text);
}
public void send(String subject, Address from, Address[] to, String text) throws Exception {
send(subject, from, null, to, null, null, text);
}

View file

@ -1,5 +1,5 @@
apply from: rootProject.file('gradle/compile/groovy.gradle')
dependencies {
api "org.xbib:files-sftp-fs:${project.property('files.version')}"
api libs.files.sftp.fs
}

View file

@ -0,0 +1 @@
version = 5.0.0

View file

@ -2,19 +2,13 @@ package org.xbib.groovy.sshd
import groovy.util.logging.Log
import org.junit.jupiter.api.Test
import org.xbib.io.sshd.eddsa.EdDSASecurityProvider
import java.nio.file.Files
import java.nio.file.Path
import java.security.Security
@Log
class SFTPTest {
static {
Security.addProvider(new EdDSASecurityProvider())
}
@Test
void testSFTP() {
SFTP sftp = SFTP.newInstance("sftp://demo.wftpserver.com:2222",[username: 'demo', password: 'demo'.toCharArray()])

View file

@ -1,8 +1,45 @@
pluginManagement {
repositories {
mavenLocal()
mavenCentral {
metadataSources {
mavenPom()
artifact()
ignoreGradleMetadataRedirection()
}
}
gradlePluginPortal()
}
}
dependencyResolutionManagement {
versionCatalogs {
libs {
version('gradle', '8.5')
version('groovy', '4.0.17')
version('spock', '2.3-groovy-4.0')
version('junit', '5.10.1')
library('groovy-core', 'org.apache.groovy', 'groovy').versionRef('groovy')
library('spock-core', 'org.spockframework', 'spock-core').versionRef('spock')
library('spock-junit4', 'org.spockframework', 'spock-junit4').versionRef('spock')
library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit')
library('junit-jupiter-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit')
library('junit-jupiter-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit')
library('junit4', 'junit', 'junit').version('4.13.2')
library('hamcrest', 'org.hamcrest', 'hamcrest-library').version('2.2')
library('ftp-fs', 'org.xbib', 'ftp-fs').version('2.6.0')
library('files-sftp-fs', 'org.xbib', 'files-sftp-fs').version('4.2.1')
library('jgit', 'org.eclipse.jgit', 'org.eclipse.jgit').version('6.8.0.202311291450-r')
library('mail', 'com.sun.mail', 'javax.mail').version('1.6.2')
}
}
}
include 'groovy-ldap'
include 'groovy-crypt'
include 'groovy-mail'
include 'groovy-ftp'
include 'groovy-ftps'
include 'groovy-sshd'
include 'groovy-git-annotations'
include 'groovy-git'
include 'groovy-ldap'
include 'groovy-mail'
include 'groovy-sshd'