提交 c4913249 编写于 作者: P poorguy-tech

change gradle setting (kotlin-related modifying is not finish)

上级 a15b1f61
......@@ -3,6 +3,10 @@ buildscript {
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
name "aliyunmaven"
url "https://maven.aliyun.com/nexus/content/groups/public/"
}
google()
mavenCentral()
}
......@@ -16,7 +20,6 @@ allprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'scala'
apply plugin: 'com.diffplug.gradle.spotless'
group = 'io.github.dreamylost'
......@@ -38,7 +41,9 @@ allprojects {
// url "https://maven.aliyun.com/repository/google"
// }
mavenLocal()
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
name "aliyunmaven"
url "https://maven.aliyun.com/nexus/content/groups/public/"
......@@ -51,19 +56,6 @@ allprojects {
mavenCentral()
}
//TODO 这个配置导致项目的层级是有问题的
sourceSets {
main {
scala.srcDirs += ['src/main/java', 'src/main/scala']
java.srcDirs = []
}
//测试的执行可能有问题,可以用IDEA rebuild单独的子模块,再执行脚本build
test {
scala.srcDirs = ['src/test/scala', 'src/test/java']
}
}
/**
* 所有项目共用Scala2.12.8
*
......@@ -73,72 +65,9 @@ allprojects {
//because some test write in src/main/java
compile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'
compile group: 'org.scala-lang', name: 'scala-library', version: '2.13.5'
compile group: 'org.scala-lang', name: 'scala-reflect', version: '2.13.5'
compile group: 'com.diffplug.spotless', name: 'spotless-plugin-gradle', version: '4.5.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
}
[compileJava, compileScala, compileTestScala, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
/**
* gradle spotlessApply
* 自动格式化Java
*/
spotless {
java {
removeUnusedImports()
googleJavaFormat('1.6').aosp()
licenseHeader '/* All Contributors (C) $YEAR */'
}
}
[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
}
/**
* gradle spotlessApply
* 格式化所有Scala项目
*/
project(':scala-leetcode') {
spotless {
scala {
scalafmt('2.6.1').configFile('../.scalafmt.conf')
licenseHeader '/* Licensed under Apache-2.0 (C) All Contributors */', 'package '
}
}
}
project(':scala-utils') {
spotless {
scala {
scalafmt('2.6.1').configFile('../.scalafmt.conf')
licenseHeader '/* Licensed under Apache-2.0 @梦境迷离 */', 'package '
}
}
}
project(':scala-examples') {
spotless {
scala {
scalafmt('2.6.1').configFile('../.scalafmt.conf')
licenseHeader '/* Licensed under Apache-2.0 @梦境迷离 */', 'package '
}
}
}
project(':kotlin-leetcode') {
spotless {
kotlin {
ktlint('0.37.2').userData(['indent_size': '4', 'continuation_indent_size': '2', 'disabled_rules': 'no-wildcard-imports'])
licenseHeader '/* Licensed under Apache-2.0 @梦境迷离 */'
}
}
}
project(':kotlin-study') {
spotless {
kotlin {
ktlint('0.37.2').userData(['indent_size': '4', 'continuation_indent_size': '2', 'disabled_rules': 'no-wildcard-imports'])
licenseHeader '/* Licensed under Apache-2.0 @梦境迷离 */'
}
}
}
\ No newline at end of file
plugins {
id 'groovy-gradle-plugin' //In order for precompiled script plugins to be discovered
}
repositories {
mavenLocal()
maven {
name "aliyunmaven"
url "https://maven.aliyun.com/nexus/content/groups/public/"
}
maven {
name "spring"
url "http://repo.spring.io/libs-milestone/"
}
google()
gradlePluginPortal() //added as a repository for plugin dependencies
mavenCentral()
}
sourceSets {
main {
java.srcDirs = ['src/main/java']
}
//测试的执行可能有问题,可以用IDEA rebuild单独的子模块,再执行脚本build
test {
java.srcDirs = ['src/test/java']
}
}
spotless {
java {
removeUnusedImports()
googleJavaFormat('1.6').aosp()
licenseHeader '/* All Contributors (C) $YEAR */'
}
}
\ No newline at end of file
version = '0.0.1'
ext {
kotlin_version = '1.4.31'
}
buildscript {
def kotlin_version='1.4.31'
//gradle的kotlin插件
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
configurations {
ktlint
}
sourceSets {
main {
kotlin {
srcDirs += 'src/main/kotlin'
}
}
test {
kotlin {
srcDirs += 'src/test/kotlin'
}
}
}
dependencies {
compile "org.jetbrains.kotlin.kotlin-stdlib:$kotlin_version"
ktlint "com.pinterest:ktlint:0.37.2"
}
task "getConfig"{
print(project.getConfigurations())
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "src/main/kotlin/**/*.kt"
}
//check.dependsOn ktlint
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "src/main/kotlin/**/*.kt"
}
spotless {
kotlin {
ktlint('0.37.2').userData(['indent_size': '4', 'continuation_indent_size': '2', 'disabled_rules': 'no-wildcard-imports'])
licenseHeader '/* Licensed under Apache-2.0 @梦境迷离 */'
}
}
\ No newline at end of file
plugins {
id 'java'
id 'scala'
}
sourceSets {
main {
scala.srcDirs = ['src/main/scala']
}
//测试的执行可能有问题,可以用IDEA rebuild单独的子模块,再执行脚本build
test {
scala.srcDirs = ['src/test/java']
}
}
dependencies {
compile group: 'org.scala-lang', name: 'scala-library', version: '2.13.5'
compile group: 'org.scala-lang', name: 'scala-reflect', version: '2.13.5'
}
[compileScala, compileTestScala]*.options*.encoding = 'UTF-8'
spotless {
scala {
scalafmt('2.6.1').configFile("${rootProject.rootDir}/.scalafmt.conf")
}
}
plugins{
id 'custom.scala'
}
spotless {
scala {
licenseHeader '/* All Contributors (C) 2020 */', 'package '
}
}
dependencies {
compile group: 'org.apache.commons', name: 'commons-csv', version: '1.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
......
/* All Contributors (C) 2020 */
package cn.edu.jxnu.examples.design.observer
// 具体的被观察者
......
plugins {
id 'custom.java'
}
/* All Contributors (C) 2021 */
package io.github.poorguy.annotation;
/** Parameter should not be null */
public @interface NotNull {}
/* All Contributors (C) 2020 */
/* All Contributors (C) 2021 */
package io.github.poorguy.explore.learn.binarysearch;
/**
......
/* All Contributors (C) 2021 */
package io.github.poorguy.explore.learn.hashtable;
public class DesignHashMap {
private class Node {
int key;
int value;
Node next;
public Node(int key, int value, Node next) {
this.key = key;
this.value = value;
this.next = next;
}
}
private Node[] list;
private static final float DEFAULT_LOAD_FACTOR = 0.75f;
private int size;
/** Initialize your data structure here. */
public DesignHashMap() {
this.list = new Node[16];
this.size = 0;
}
/** value will always be non-negative. */
public void put(int key, int value) {
int exist = get(key);
if (exist != -1) {
Node pointer = list[indexOf(key)];
while (pointer != null && pointer.key != key) {
pointer = pointer.next;
}
assert pointer != null;
pointer.value = value;
return;
}
// add new node
if (size + 1 > list.length * DEFAULT_LOAD_FACTOR) {
expend();
}
int index = indexOf(key);
Node node = list[index];
if (node == null) {
list[index] = new Node(key, value, null);
} else {
Node pointer = node;
while (pointer.next != null) {
pointer = pointer.next;
}
pointer.next = new Node(key, value, null);
}
size++;
}
/**
* Returns the value to which the specified key is mapped, or -1 if this map contains no mapping
* for the key
*/
public int get(int key) {
int index = indexOf(key);
Node pointer = list[index];
while (pointer != null && pointer.key != key) {
pointer = pointer.next;
}
if (pointer == null) {
return -1;
}
return pointer.value;
}
/** Removes the mapping of the specified value key if this map contains a mapping for the key */
public void remove(int key) {
int index = indexOf(key);
Node pointer = list[index];
if (pointer == null) {
return;
}
Node next = pointer.next;
if (next == null && pointer.key == key) {
list[index] = null;
size--;
return;
}
while (next != null) {
if (next.key == key) {
pointer.next = next.next;
size--;
return;
}
pointer = pointer.next;
next = next.next;
}
}
private int indexOf(int key) {
return (key ^ (key >>> 16)) & (list.length - 1);
}
private int indexOf(int key, int listLength) {
return (key ^ (key >>> 16)) & (listLength - 1);
}
private void expend() {
Node[] newList = new Node[list.length * 2];
for (Node node : list) {
if (node != null) {
int newIndex = indexOf(node.key, newList.length);
newList[newIndex] = node;
Node pointer = node;
while (pointer.next != null) {
pointer = pointer.next;
int newIndex2 = indexOf(pointer.key, newList.length);
newList[newIndex2] = pointer;
}
}
}
this.list = newList;
}
public static void main(String[] args) {
DesignHashMap map = new DesignHashMap();
String[] methods = {
"remove", "put", "remove", "remove", "get", "remove", "put", "get", "remove", "put",
"put", "put", "put", "put", "put", "put", "put", "put", "put", "put", "remove", "put",
"put", "get", "put", "get", "put", "put", "get", "put", "remove", "remove", "put",
"put", "get", "remove", "put", "put", "put", "get", "put", "put", "remove", "put",
"remove", "remove", "remove", "put", "remove", "get", "put", "put", "put", "put",
"remove", "put", "get", "put", "put", "get", "put", "remove", "get", "get", "remove",
"put", "put", "put", "put", "put", "put", "get", "get", "remove", "put", "put", "put",
"put", "get", "remove", "put", "put", "put", "put", "put", "put", "put", "put", "put",
"put", "remove", "remove", "get", "remove", "put", "put", "remove", "get", "put", "put"
};
int[][] params = {
{27}, {65, 65}, {19}, {0}, {18}, {3}, {42, 0}, {19}, {42}, {17, 90}, {31, 76}, {48, 71},
{5, 50}, {7, 68}, {73, 74}, {85, 18}, {74, 95}, {84, 82}, {59, 29}, {71, 71}, {42},
{51, 40}, {33, 76}, {17}, {89, 95}, {95}, {30, 31}, {37, 99}, {51}, {95, 35}, {65},
{81}, {61, 46}, {50, 33}, {59}, {5}, {75, 89}, {80, 17}, {35, 94}, {80}, {19, 68},
{13, 17}, {70}, {28, 35}, {99}, {37}, {13}, {90, 83}, {41}, {50}, {29, 98}, {54, 72},
{6, 8}, {51, 88}, {13}, {8, 22}, {85}, {31, 22}, {60, 9}, {96}, {6, 35}, {54}, {15},
{28}, {51}, {80, 69}, {58, 92}, {13, 12}, {91, 56}, {83, 52}, {8, 48}, {62}, {54}, {25},
{36, 4}, {67, 68}, {83, 36}, {47, 58}, {82}, {36}, {30, 85}, {33, 87}, {42, 18},
{68, 83}, {50, 53}, {32, 78}, {48, 90}, {97, 95}, {13, 8}, {15, 7}, {5}, {42}, {20},
{65}, {57, 9}, {2, 41}, {6}, {33}, {16, 44}, {95, 30}
};
Integer[] expectedResult = {
null, null, null, null, -1, null, null, -1, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, 90, null, -1, null, null, 40, null,
null, null, null, null, 29, null, null, null, null, 17, null, null, null, null, null,
null, null, null, null, 33, null, null, null, null, null, null, 18, null, null, -1,
null, null, -1, 35, null, null, null, null, null, null, null, -1, -1, null, null, null,
null, null, -1, null, null, null, null, null, null, null, null, null, null, null, null,
null, -1, null, null, null, null, 87, null, null
};
for (int i = 0; i < methods.length; i++) {
switch (methods[i]) {
case "remove":
map.remove(params[i][0]);
break;
case "put":
map.put(params[i][0], params[i][1]);
break;
case "get":
Integer val = map.get(params[i][0]);
if (!val.equals(expectedResult[i])) {
System.out.println(i + " ");
}
break;
}
}
}
}
/* All Contributors (C) 2021 */
package io.github.poorguy.util;
import io.github.poorguy.annotation.NotNull;
import java.lang.reflect.Method;
public class LeetcodeRunner<T> {
/** @param invoker 调用该工具方法的对象 */
public <C> void run(@NotNull C invoker, @NotNull String[] functionNames, @NotNull T[][] params)
throws Exception {
if (functionNames.length != params.length) {
throw new Exception("参数数目错误");
}
Method[] methods = invoker.getClass().getMethods();
for (Method method : methods) {
System.out.println(method.getName());
}
for (int i = 0; i < functionNames.length; i++) {}
}
public static void main(String[] args) throws Exception {
LeetcodeRunner<String> runner = new LeetcodeRunner<>();
runner.run(runner, new String[0], new String[0][0]);
}
}
plugins{
id 'custom.java'
}
group 'io.github.dreamylost.utils'
version '0.0.1'
......
version = '0.0.1'
group = 'io.github.dreamylost'
buildscript {
ext.kotlin_version = '1.4.31'
//编译插件的依赖仓库
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
maven {
name "aliyunmaven"
url "https://maven.aliyun.com/nexus/content/groups/public/"
}
}
//gradle的kotlin插件
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
configurations {
ktlint
}
sourceSets {
main {
kotlin {
srcDirs += 'src/main/kotlin'
}
}
test {
kotlin {
srcDirs += 'src/test/kotlin'
}
}
}
//项目本身的依赖仓库
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
maven { url "https://repo.maven.apache.org/maven2" }
maven {
name "aliyunmaven"
url "https://maven.aliyun.com/nexus/content/groups/public/"
}
}
dependencies {
compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version
ktlint "com.pinterest:ktlint:0.37.2"
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "src/main/kotlin/**/*.kt"
}
//check.dependsOn ktlint
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "src/main/kotlin/**/*.kt"
plugins{
id 'custom.kotlin'
}
\ No newline at end of file
version = '0.0.1'
group = 'io.github.dreamylost'
buildscript {
ext.kotlin_version = "1.4.31"
//编译插件的依赖仓库
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
maven { url "https://repo.maven.apache.org/maven2" }
maven {
name "aliyunmaven"
url "https://maven.aliyun.com/nexus/content/groups/public/"
}
}
//gradle的kotlin插件
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
configurations {
ktlint
}
sourceSets {
main {
kotlin {
srcDirs += 'src/main/kotlin'
}
}
test {
kotlin {
srcDirs += 'src/test/kotlin'
}
}
}
//项目本身的依赖仓库
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
maven { url "https://repo.maven.apache.org/maven2" }
maven {
name "aliyunmaven"
url "https://maven.aliyun.com/nexus/content/groups/public/"
}
}
dependencies {
compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version
ktlint "com.pinterest:ktlint:0.37.2"
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "src/main/kotlin/**/*.kt"
}
//check.dependsOn ktlint
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "src/main/kotlin/**/*.kt"
plugins{
id 'custom.kotlin'
}
\ No newline at end of file
plugins{
id 'custom.scala'
}
dependencies {
compile group: 'com.typesafe.play', name: 'play_2.13', version: '2.7.9'
}
\ No newline at end of file
plugins{
id 'custom.scala'
}
spotless {
scala {
licenseHeader '/* Licensed under Apache-2.0 (C) All Contributors */', 'package '
}
}
\ No newline at end of file
plugins{
id 'custom.scala'
}
spotless {
scala {
licenseHeader '/* Licensed under Apache-2.0 @梦境迷离 */', 'package '
}
}
dependencies {
compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
compile group: 'com.typesafe.scala-logging', name: 'scala-logging_2.13', version: '3.9.2'
......@@ -13,5 +21,4 @@ dependencies {
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-scala_2.13', version: '2.12.2'
compile group: 'org.tpolecat', name: 'doobie-core_2.13', version: '0.10.0'
compile group: 'org.postgresql', name: 'postgresql', version: '42.2.5'
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册