Skip to content

Commit

Permalink
Add: GroupIdFilterChain
Browse files Browse the repository at this point in the history
  • Loading branch information
shalousun committed May 14, 2023
1 parent ab72a51 commit f7ed654
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* smart-doc https://github.com/shalousun/smart-doc
* smart-doc https://github.com/smart-doc-group/smart-doc
*
* Copyright (C) 2018-2023 smart-doc
*
Expand All @@ -22,7 +22,6 @@
*/
package com.smartdoc.gradle.chain;


import com.smartdoc.gradle.model.CustomArtifact;

/**
Expand All @@ -41,12 +40,6 @@ public void setNext(FilterChain nextInChain) {
public boolean ignoreArtifactById(CustomArtifact artifact) {
String artifactId = artifact.getArtifactId();
switch (artifactId) {
case "aspectjweaver":
case "fastjson":
case "fastjson2":
case "bcprov-jdk15on":
case "bcpkix-jdk15on":
case "lombok":
case "jsqlparser":
case "disruptor":
case "snakeyaml":
Expand All @@ -57,32 +50,43 @@ public boolean ignoreArtifactById(CustomArtifact artifact) {
case "mysql-connector-j":
case "classmate":
case "commons-codec":
case "commons-lang3":
case "commons-text":
case "commons-beanutils":
case "commons-beanutils-core":
case "spring-web":
case "spring-webmvc":
case "spring-r2dbc":
case "spring-orm":
case "spring-data-jpa":
case "spring-context-support":
case "spring-aspects":
case "hibernate-validator":
case "xstream":
case "spring-tx":
case "javassist":
case "javafaker":
case "qdox":
case "gson":
case "netty-all":
case "javacv-platform":
case "antlr4-runtime":
case "jetty":
case "velocity":
case "beetl":
case "xml-apis":
case "mchange-commons-java":
case "hadoop-common":
case "druid":
case "mssql-jdbc":
case "easyexcel":
case "zookeeper":
case "okio":
case "okhttp":
case "joda-time":
case "protobuf-java":
case "jenkins-client":
case "jose4j":
case "gson-fire":
case "joda-convert":
case "kafka-clients":
case "kubernetes-client":
case "client-java-proto":
case "dynamic-datasource-spring-boot-starter":
return true;
default:
return this.ignore(filterChain, artifact);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* smart-doc https://github.com/shalousun/smart-doc
* smart-doc https://github.com/smart-doc-group/smart-doc
*
* Copyright (C) 2018-2023 smart-doc
*
Expand Down Expand Up @@ -34,16 +34,18 @@ public class ContainsFilterChain implements FilterChain {

private final static Set<String> CONTAINS_SET = new HashSet<>();

private FilterChain filterChain;

static {
CONTAINS_SET.add("log4j");
CONTAINS_SET.add("logback");
CONTAINS_SET.add("slf4j");
CONTAINS_SET.add("swagger");
CONTAINS_SET.add("dom4j");
CONTAINS_SET.add("jsr");
CONTAINS_SET.add("jtds");
}

private FilterChain filterChain;

@Override
public void setNext(FilterChain nextInChain) {
this.filterChain = nextInChain;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/smartdoc/gradle/chain/FilterChain.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* smart-doc https://github.com/shalousun/smart-doc
* smart-doc https://github.com/smart-doc-group/smart-doc
*
* Copyright (C) 2018-2023 smart-doc
*
Expand Down
108 changes: 108 additions & 0 deletions src/main/java/com/smartdoc/gradle/chain/GroupIdFilterChain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* smart-doc https://github.com/smart-doc-group/smart-doc
*
* Copyright (C) 2018-2023 smart-doc
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 com.smartdoc.gradle.chain;

import com.smartdoc.gradle.model.CustomArtifact;

import java.util.HashSet;
import java.util.Set;

/**
* @author yu 2023/5/10.
*/
public class GroupIdFilterChain implements FilterChain{

private final static Set<String> GROUPID_SET = new HashSet<>();

static {
GROUPID_SET.add("org.apache.commons");
GROUPID_SET.add("io.fabric8");
GROUPID_SET.add("io.kubernetes");
GROUPID_SET.add("org.jooq");
GROUPID_SET.add("org.mortbay.jetty");
GROUPID_SET.add("com.google.http-client");
GROUPID_SET.add("jakarta.xml.bind");
GROUPID_SET.add("org.mariadb.jdbc");
GROUPID_SET.add("jakarta.transaction");
GROUPID_SET.add("jakarta.persistence");
GROUPID_SET.add("javax.servlet");
GROUPID_SET.add("io.projectreactor");
GROUPID_SET.add("org.mapstruct");
GROUPID_SET.add("io.sundr");
GROUPID_SET.add("org.aspectj");
GROUPID_SET.add("org.slf4j");
GROUPID_SET.add("com.esotericsoftware.yamlbeans");
GROUPID_SET.add("jakarta.activation");
GROUPID_SET.add("commons-httpclient");
GROUPID_SET.add("org.apache.curator");
GROUPID_SET.add("org.apache.hive");
GROUPID_SET.add("org.apache.hadoop");
GROUPID_SET.add("org.hibernate");
GROUPID_SET.add("org.bouncycastle");
GROUPID_SET.add("io.vavr");
GROUPID_SET.add("org.projectlombok");
GROUPID_SET.add("org.freemarker");
GROUPID_SET.add("com.auth0");
GROUPID_SET.add("org.apache.logging.log4j");
GROUPID_SET.add("com.google.protobuf");
GROUPID_SET.add("org.postgresql");
GROUPID_SET.add("com.microsoft.sqlserver");
GROUPID_SET.add("io.etcd");
GROUPID_SET.add("org.apache.flink");
GROUPID_SET.add("org.apache.rocketmq");
GROUPID_SET.add("org.apache.kafka");
GROUPID_SET.add("org.apache.hudi");
GROUPID_SET.add("com.rabbitmq");
GROUPID_SET.add("org.apache.dubbo");
GROUPID_SET.add("cn.hutool");
GROUPID_SET.add("com.alibaba.nacos");
GROUPID_SET.add("com.alibaba.csp");
GROUPID_SET.add("io.zipkin.zipkin2");
GROUPID_SET.add("org.apache.skywalking");
GROUPID_SET.add("com.ctrip.framework.apollo");
GROUPID_SET.add("org.apache.shardingsphere");
GROUPID_SET.add("ru.yandex.clickhouse");
GROUPID_SET.add("com.clickhouse");
GROUPID_SET.add("org.apache.activemq");
GROUPID_SET.add("org.bytedeco");
GROUPID_SET.add("ws.schild");
GROUPID_SET.add("io.netty");
GROUPID_SET.add("io.micrometer");
GROUPID_SET.add("org.apache.pulsar");
}
private FilterChain filterChain;
@Override
public void setNext(FilterChain nextInChain) {
this.filterChain = nextInChain;
}

@Override
public boolean ignoreArtifactById(CustomArtifact artifact) {
String groupId = artifact.getGroupId();
if (GROUPID_SET.stream().anyMatch(groupId::contains)) {
return true;
}
return this.ignore(filterChain, artifact);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* smart-doc https://github.com/shalousun/smart-doc
* smart-doc https://github.com/smart-doc-group/smart-doc
*
* Copyright (C) 2018-2023 smart-doc
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* smart-doc https://github.com/shalousun/smart-doc
* smart-doc https://github.com/smart-doc-group/smart-doc
*
* Copyright (C) 2018-2023 smart-doc
*
Expand Down Expand Up @@ -34,8 +34,6 @@ public class StartsWithFilterChain implements FilterChain {

private final static Set<String> PREFIX_SET = new HashSet<>();

private FilterChain filterChain;

static {
PREFIX_SET.add("maven");
PREFIX_SET.add("asm");
Expand Down Expand Up @@ -70,8 +68,16 @@ public class StartsWithFilterChain implements FilterChain {
PREFIX_SET.add("springfox");
PREFIX_SET.add("elasticsearch");
PREFIX_SET.add("guava");
PREFIX_SET.add("fastjson");
PREFIX_SET.add("bcprov");
PREFIX_SET.add("aws-java-sdk");
PREFIX_SET.add("hadoop");
PREFIX_SET.add("xml");
PREFIX_SET.add("sundr-codegen");
}

private FilterChain filterChain;

@Override
public void setNext(FilterChain nextInChain) {
this.filterChain = nextInChain;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/smartdoc/gradle/model/CustomArtifact.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class CustomArtifact {
/**
* Artifact Group
*/
private String group;
private String groupId;

/**
* Artifact Version
Expand Down Expand Up @@ -80,12 +80,12 @@ public CustomArtifact setArtifactId(String artifactId) {
return this;
}

public String getGroup() {
return group;
public String getGroupId() {
return groupId;
}

public CustomArtifact setGroup(String group) {
this.group = group;
this.groupId = group;
return this;
}

Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/smartdoc/gradle/util/ArtifactFilterUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
import com.smartdoc.gradle.chain.*;
import com.smartdoc.gradle.model.CustomArtifact;

import java.util.Set;
import java.util.regex.Pattern;


/**
* Artifact filter util
Expand All @@ -43,12 +40,17 @@ public class ArtifactFilterUtil {
* @return boolean
*/
public static boolean ignoreArtifact(CustomArtifact artifact) {
FilterChain groupFilterChain = new GroupIdFilterChain();
FilterChain startsWithFilterChain = new StartsWithFilterChain();
FilterChain containsFilterChain = new ContainsFilterChain();
FilterChain commonArtifactFilterChain = new CommonArtifactFilterChain();
FilterChain springBootArtifactFilterChain = new SpringBootArtifactFilterChain();

groupFilterChain.setNext(startsWithFilterChain);
startsWithFilterChain.setNext(containsFilterChain);
containsFilterChain.setNext(commonArtifactFilterChain);
return startsWithFilterChain.ignoreArtifactById(artifact);
commonArtifactFilterChain.setNext(springBootArtifactFilterChain);
return groupFilterChain.ignoreArtifactById(artifact);
}

/**
Expand Down

0 comments on commit f7ed654

Please sign in to comment.