Skip to content

Commit 335bc69

Browse files
committed
* Implemented local artifacts directory
Signed-off-by: Marcin Kuszczak <1508798+aartiPl@users.noreply.github.com>
1 parent c19f659 commit 335bc69

9 files changed

Lines changed: 93 additions & 60 deletions

File tree

NEWS.md

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Changes
22

3-
## 4.2.0-SNAPSHOT
3+
## [4.2.0-SNAPSHOT] - 2022-11-25
44

5-
Enhancements
5+
**Breaking changes**
6+
7+
* Renamed environment variable from 'KSCRIPT_DIR' to 'KSCRIPT_DIRECTORY'
8+
9+
**Enhancements**
610

711
* New GitHub organization: [kscripting](http://github.com/kscripting)
812
* Change the name of kscript package to io.github.kscripting:kscript
@@ -17,49 +21,50 @@ Enhancements
1721
* Changed the way of creating distribution package - now it is handled by Gradle
1822
* Version of kscript is set by Gradle (generated BuildConfig class)
1923
* Improved DependencyResolver: aar archives are also included in classpath
20-
* Gradle and Idea are no more needed for generation of IntelliJ project
24+
* When creating IntelliJ project Gradle and Idea are no more required
25+
* Ability to provide local artifacts path through KSCRIPT_DIRECTORY_ARTIFACTS or configuration file property:
26+
scripting.directory.artifacts (thanks to [Vsajip](https://github.com/vsajip) for initial implementation)
2127

22-
Bugfixes
28+
**Bugfixes**
2329

2430
* Fixed exit code on Windows
2531

26-
## 4.1.0
32+
## [4.1.x] - (last 4.1.1 - 2022-08-27)
2733

28-
Breaking changes
34+
**Breaking changes**
2935

30-
* Renamed env variables (cleanup):
36+
* Renamed env variables (cleanup):
3137
CUSTOM_KSCRIPT_PREAMBLE -> KSCRIPT_PREAMBLE
3238
KSCRIPT_IDEA_COMMAND -> KSCRIPT_COMMAND_IDEA
3339
KSCRIPT_GRADLE_COMMAND -> KSCRIPT_COMMAND_GRADLE
3440

35-
Enhancements
41+
**Enhancements**
3642

3743
* Windows support and proper Cygwin and MSys support
3844
* File argument for specific OS should be in format of that OS (eg. Cygwin: kscript /cygdrive/c/file.kts)
3945
* Multiplatform tests for different OS-es using Github actions
40-
* Ability to use configuration file for kscript (thanks to [meztihn](https://github.com/meztihn))
46+
* Ability to use configuration file for kscript (thanks to [meztihn](https://github.com/meztihn))
4147
* kscript follows XDG Spec (Issue #323) (thanks to [meztihn](https://github.com/meztihn))
4248
* Packaging scripts works again (thanks to [Vsajip](https://github.com/vsajip))
4349
* When creating IntelliJ project 'gradle' and 'idea' do not have to be in path
4450
* Integration tests rewritten from bash to JUnit
4551
* Replacements for (current annotations are deprecated):
46-
* @MavenRepository -> @Repository
47-
* @KotlinOpts -> @KotlinOptions
48-
* @CompilerOpts -> @CompilerOptions
52+
* @MavenRepository -> @Repository
53+
* @KotlinOpts -> @KotlinOptions
54+
* @CompilerOpts -> @CompilerOptions
4955
* Deprecation of comment based annotations
5056
* Report for deprecated features (--report option)
5157

52-
Bugfixes
58+
**Bugfixes**
59+
5360
* Fix for dependency resolution
5461
* Fix for creation of Gradle files and their indentation
5562
* Fix for handling potentially duplicated file names in Idea projects
5663
* Fix for Idea runtime configuration
5764

58-
## 4.0.x (last 4.0.3)
59-
60-
Released 2022-05-18
65+
## [4.0.x] - (last 4.0.3 - 2022-05-28)
6166

62-
Rewrite by https://github.com/aartiPl
67+
**Rewrite by https://github.com/aartiPl**
6368

6469
Functionality:
6570

@@ -115,7 +120,7 @@ INCOMPATIBLE CHANGES:
115120
not good to include arbitrary strings from user env into the script)
116121
* Reworked caching mechanism
117122

118-
## 3.2
123+
## [3.2]
119124

120125
Not released - incorporated in 4.0
121126

@@ -125,14 +130,14 @@ Major changes & enhancements
125130
aartiPI** [#330](https://github.com/holgerbrandl/kscript/pull/330))
126131
* Fixed bootstrap header support ([#324](https://github.com/holgerbrandl/kscript/issues/324))
127132

128-
## 3.1
133+
## [3.1]
129134

130135
Major changes & enhancements
131136

132137
* Removed jcenter as default dependency repository
133138
* Updated tests and build integration to function without jcenter
134139

135-
## 3.0
140+
## [3.0]
136141

137142
Major Enhancements
138143

@@ -161,7 +166,7 @@ Incompatible API changes
161166
as `org.javamoney:moneta:1.3@pom`)
162167
* Dynamic version dependencies must be now declared as `log4j:log4j:[1.2,)` (and no longer as `log4j:log4j:1.2+`)
163168

164-
## 2.9
169+
## [2.9]
165170

166171
Support environment variables in repository credentials ([#248](https://github.com/holgerbrandl/kscript/issues/159))
167172

@@ -176,15 +181,15 @@ Minor enhancements & fixes:
176181
* Fixed bootstrap header ([#234](https://github.com/holgerbrandl/kscript/issues/159))
177182
* Improved and documented basic testing support ([#247](https://github.com/holgerbrandl/kscript/issues/159))
178183

179-
## 2.8
184+
## [2.8]
180185

181186
Improvements & Fixes
182187

183188
* [#214](https://github.com/holgerbrandl/kscript/pull/214) Added credentials support for `@file:MavenRepository`
184189
annotation (thanks to [@meonlol](https://github.com/meonlol)
185190
for providing the PR and his patience)
186191

187-
## 2.7
192+
## [2.7]
188193

189194
Improvements & Fixes
190195

@@ -197,7 +202,7 @@ Improvements & Fixes
197202
with `--add-bootstrap-header`
198203
* [#200](https://github.com/holgerbrandl/kscript/issues/200): Expose script file name to script
199204

200-
## v2.6
205+
## [2.6]
201206

202207
Major Improvements
203208

@@ -215,7 +220,7 @@ Notable Bug Fixes
215220
* Fixed usage `@file:CompilerOpts` in combination with `@file:Include`
216221
* Renamed `kshell_from_kscript` to `kshell_kts`
217222

218-
## v2.5
223+
## [2.5]
219224

220225
Major Improvements
221226

@@ -231,7 +236,7 @@ Minor Enhancements
231236
* Allow to include same file from multiple files
232237
* Fixed: Space-containing argument propagation
233238

234-
## v2.4
239+
## [2.4]
235240

236241
Major Enhancements:
237242

@@ -253,7 +258,7 @@ Minor Enhancements:
253258
* Simplify Gradle config for script bootstrapping with IDEA (#86)
254259
* Added Gradle wrapper to the project (#87 and #88)
255260

256-
## v2.3
261+
## [2.3]
257262

258263
Major Enhancements:
259264

@@ -281,7 +286,7 @@ Minor Enhancements:
281286
* Simplified build instructions (fixes [#60](https://github.com/holgerbrandl/kscript/issues/60))
282287
* Document dependencies of kscript (fixes [#69](https://github.com/holgerbrandl/kscript/issues/69))
283288

284-
## v2.2
289+
## [2.2]
285290

286291
* Logging of maven artifact downloads to stderr (fixes [#23](https://github.com/holgerbrandl/kscript/issues/23))
287292
* Added `-s` / `--silent` to suppress all logging
@@ -293,12 +298,12 @@ Minor Enhancements:
293298

294299
See [README.md](README.md) for usage details.
295300

296-
## v2.1
301+
## [2.1]
297302

298303
* support for annotation-driven script configuration
299304
* refactored support api mode into `-t` parameter
300305

301-
## v2.0
306+
## [2.0]
302307

303308
* Reimplemented in kotlin (fixes [#36](https://github.com/holgerbrandl/kscript/issues/36))
304309
* Added cygwin support (fixes [#39](https://github.com/holgerbrandl/kscript/issues/39))
@@ -307,25 +312,25 @@ See [README.md](README.md) for usage details.
307312
argument ([#40](https://github.com/holgerbrandl/kscript/issues/40)
308313
* Fixed compatibility with java9 ([#41](https://github.com/holgerbrandl/kscript/issues/41))
309314

310-
## v1.5.1
315+
## [1.5.1]
311316

312317
* Fixed `--self-update`
313318
* More robust self-update on OSses with file-locking (e.g. windows)
314319

315-
## v1.5
320+
## [1.5]
316321

317322
* removed `curl` dependency
318323
* more streamlined dependency lookup
319324

320-
## v1.4
325+
## [1.4]
321326

322327
Major new features
323328

324329
* Redesigned [support library](https://github.com/holgerbrandl/kscript-support-api) for streamlined tabular data
325330
processing. See [here](http://holgerbrandl.github.io/kotlin/2017/05/08/kscript_as_awk_substitute.html) for an
326331
overview.
327332

328-
## v1.3
333+
## [1.3]
329334

330335
Major new features
331336

@@ -356,7 +361,7 @@ Other changes
356361
* More heuristics to guess `KOTLIN_HOME`
357362
* Cache cleanup `--clear-cache` now applies to jars, scripts, urls, and cached dependency lookups
358363

359-
## v1.2
364+
## [1.2]
360365

361366
* Fixed compatibility with [Kotlin v1.1](https://kotlinlang.org/docs/reference/whatsnew11.html)
362367
(fixes [#15](https://github.com/holgerbrandl/kscript/issues/15))
@@ -365,7 +370,7 @@ Other changes
365370
* Compile jars should go to TEMP (fixes [#13](https://github.com/holgerbrandl/kscript/issues/13))
366371
* started test-suite
367372

368-
## v1.1
373+
## [1.1]
369374

370375
* Support for stdin and process substitution as script source. See [examples](examples)
371376
* versioning and auto-update
@@ -374,6 +379,6 @@ Other changes
374379
* Added CLI help to `resdeps.kts`
375380
* Added option to clear dependency lookup cache: `resdeps.kts --clear-cache`
376381

377-
## v1.0
382+
## [1.0]
378383

379384
Initial Release

TODO.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
* Release kscript to Maven Central
44
* Change a way of executing .kts files (investigate if we can get rid of reflections)
5-
* Switched to java executor; it works faster, and can handle multiple jars on classpath with asterisk
65
* Fix the bug on ArchLinux
7-
* Local jars path (ticket)
86
* Onboard on brew
9-
* Deprecate KotlinOptions
7+
* Test local artifacts directory
108

9+
* Deprecate KotlinOptions
1110
* New package for Windows e.g. scoop
1211
* Release scripts in Kotlin
1312
* Windows console support requires @argfiles as kotlin/kotlinc command line might be too long to execute it from console (especially for big classpaths).

src/main/kotlin/io/github/kscripting/kscript/KscriptHandler.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import io.github.kscripting.kscript.model.Config
77
import io.github.kscripting.kscript.parser.Parser
88
import io.github.kscripting.kscript.resolver.*
99
import io.github.kscripting.kscript.util.Executor
10+
import io.github.kscripting.kscript.util.FileUtils.getArtifactsRecursively
1011
import io.github.kscripting.kscript.util.Logger
1112
import io.github.kscripting.kscript.util.Logger.info
1213
import io.github.kscripting.kscript.util.Logger.infoMsg
@@ -63,14 +64,20 @@ class KscriptHandler(private val config: Config, private val options: Map<String
6364
if (script.deprecatedItems.isNotEmpty()) {
6465
if (options.getBoolean("report")) {
6566
info(DeprecatedInfoCreator().create(script.deprecatedItems))
66-
} else {
67-
warnMsg("There are deprecated features in scripts. Use --report option to print full report.")
67+
return
6868
}
69+
70+
warnMsg("There are deprecated features in scripts. Use --report option to print full report.")
6971
}
7072

73+
val localArtifacts = if (config.scriptingConfig.artifactsDir != null) {
74+
getArtifactsRecursively(config.scriptingConfig.artifactsDir)
75+
} else emptyList()
76+
7177
val resolvedDependencies = cache.getOrCreateDependencies(script.digest) {
7278
DependencyResolver(script.repositories).resolve(script.dependencies)
73-
}
79+
} + localArtifacts
80+
7481
val executor = Executor(CommandResolver(config.osConfig), config.osConfig)
7582

7683
// Create temporary dev environment

src/main/kotlin/io/github/kscripting/kscript/model/Config.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ data class ScriptingConfig(
88
val providedKotlinOpts: String,
99
val providedRepositoryUrl: String,
1010
val providedRepositoryUser: String,
11-
val providedRepositoryPassword: String
11+
val providedRepositoryPassword: String,
12+
val artifactsDir: OsPath?
1213
) {
1314
override fun toString(): String {
1415
return """|ScriptingConfig {
@@ -17,6 +18,7 @@ data class ScriptingConfig(
1718
| providedRepositoryUrl: $providedRepositoryUrl
1819
| providedRepositoryUser: $providedRepositoryUser
1920
| providedRepositoryPassword: $providedRepositoryPassword
21+
| artifactsDir: $artifactsDir
2022
|}
2123
""".trimMargin()
2224
}

0 commit comments

Comments
 (0)