Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Code drop
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Jun 9, 2018
0 parents commit c5edc8a
Show file tree
Hide file tree
Showing 16 changed files with 1,145 additions and 0 deletions.
106 changes: 106 additions & 0 deletions .gitignore
@@ -0,0 +1,106 @@
###OSX###

.DS_Store
.AppleDouble
.LSOverride

# Icon must ends with two \r.
Icon


# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes


###Linux###

*~

# KDE directory preferences
.directory


###Android###

# Built application files
*.apk
*.ap_

# Files for ART and Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
.gradletasknamecache
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Lint
lint-report.html
lint-report_files/
lint_result.txt

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

# Package Files #
*.war
*.ear

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


###IntelliJ###

*.iml
*.ipr
*.iws
.idea/


###Eclipse###

*.pydevproject
.metadata
tmp/
*.tmp
*.bak
*.swp
*~.nib
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath

# sbteclipse plugin
.target

# TeXlipse plugin
.texlipse
39 changes: 39 additions & 0 deletions README.md
@@ -0,0 +1,39 @@
CopyDynamic
===========

PoC prototype of generating `copyDynamic` extension functions for data classes, such that you can do this:

```kotlin
@CopyDynamic
data class Foo(val bar: String = "bar", val baz: String = "baz", val fizz: String = "fizz")
```

And have a `copyDynamic` extension function generated to allow for dynamic setting of variables in a copy call.

```kotlin
val foo = Foo()

val newFoo = foo.copyDynamic {
bar = "newBar"
if (someCondition) baz = "newBaz"
}
```



License
-------

Copyright (C) 2018 Zac Sweers

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.
26 changes: 26 additions & 0 deletions build.gradle
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2018 Zac Sweers
*
* 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.
*/

allprojects {
buildscript {
repositories {
mavenCentral()
}
}
repositories {
mavenCentral()
}
}
41 changes: 41 additions & 0 deletions copydynamic-annotations/build.gradle
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2018 Zac Sweers
*
* 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.
*/

buildscript {
ext.kotlin_version = '1.2.41'
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

group 'com.example'
version '1.0-SNAPSHOT'

apply plugin: 'org.jetbrains.kotlin.jvm'

repositories {
mavenCentral()
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

compileKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
}
}
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2018 Zac Sweers
*
* 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.
*/

package io.sweers.copydynamic.annotations

import kotlin.annotation.AnnotationRetention.BINARY
import kotlin.annotation.AnnotationTarget.CLASS
import kotlin.annotation.AnnotationTarget.TYPE

@Target(TYPE, CLASS)
@Retention(BINARY)
annotation class CopyDynamic
50 changes: 50 additions & 0 deletions copydynamic/build.gradle
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2018 Zac Sweers
*
* 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.
*/

buildscript {
ext.kotlin_version = '1.2.41'
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.kotlin.kapt'

repositories {
mavenCentral()
maven {
url "https://kotlin.bintray.com/kotlinx"
}
}

dependencies {
kapt "com.google.auto.service:auto-service:1.0-rc4"
compileOnly "com.google.auto.service:auto-service:1.0-rc4"

compile project(':copydynamic-annotations')

compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile 'com.squareup:kotlinpoet:0.7.0'
compile 'org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.0.2'
}

compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = ['-Xjsr305=strict']
}
}

0 comments on commit c5edc8a

Please sign in to comment.