Skip to content

Commit

Permalink
feat: 指定模块统一打包插件 TencentBlueKing#8672
Browse files Browse the repository at this point in the history
  • Loading branch information
fcfang123 committed Oct 18, 2023
1 parent 73d0f8e commit 4ae4fc4
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ tasks.register("multiBootJar") {
isSpecifiedModulePath(it.path, multiModuleList)
}.forEach { subProject -> addDependencies(subProject.path) }
dependsOn("copyToRelease")
dependsOn("bootRun")
// dependsOn("jib")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.tencent.devops.auth.service

import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import javax.annotation.PostConstruct


@Component
class MyStartupTask {
@PostConstruct
fun init() {
logger.info("MyStartupTask init")
}

companion object {
private val logger = LoggerFactory.getLogger(MyStartupTask::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DataSourceDefinitionRegistrar : ImportBeanDefinitionRegistrar {

companion object {
private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java)
private val multiDataSource = listOf("auth","image").filterNot { it == "process" }
private val multiDataSource = listOf("auth", "image", "process")
private val regex = Regex("""ENC\((.*?)\)""")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class JooqDefinitionRegistrar : ImportBeanDefinitionRegistrar {
importBeanNameGenerator: BeanNameGenerator
) {
multiDataSource.forEach { dataSource ->
val finalDataSource = if (dataSource == "process") "shardingDataSource" else "${dataSource}DataSource"
//if (dataSource == "process") "shardingDataSource" else
val finalDataSource = "${dataSource}DataSource"
val connectionProvider = BeanDefinitionBuilder.genericBeanDefinition(
DataSourceConnectionProvider::class.java
).addConstructorArgReference(finalDataSource)
Expand All @@ -40,6 +41,6 @@ class JooqDefinitionRegistrar : ImportBeanDefinitionRegistrar {

companion object {
private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java)
private val multiDataSource = listOf("auth","image").filterNot { it == "process" }
private val multiDataSource = listOf("auth", "image", "process")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class MutijarDslContextConfiguration {

companion object {
private val logger = LoggerFactory.getLogger(MutijarDslContextConfiguration::class.java)
private val multiModelService = listOf("auth","image").filterNot { it == "process" }
private val multiModelService = listOf("auth", "image", "process")
private val lambdaServiceRegex = "\\.(tsource|ttarget|process|project|store)".toRegex()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ class MeasureServiceImpl : MeasureService {
@Autowired
lateinit var buildVariableService: BuildVariableService
@Autowired
lateinit var dslContext: DSLContext
@Autowired
lateinit var templateService: TemplateService
@Autowired
lateinit var pipelineInfoService: PipelineInfoService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

@Service("BkVarProcessor")
class BkVarProcessorService : ProcessorService {
class BkVarProcessorService constructor(
private val dslContext: DSLContext
) : ProcessorService {

@Autowired
private lateinit var dslContext: DSLContext

@Autowired
private lateinit var pipelineBuildVarDao: PipelineBuildVarDao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ import com.tencent.devops.process.webhook.CodeWebhookEventDispatcher
import com.tencent.devops.process.webhook.pojo.event.commit.GithubWebhookEvent
import org.springframework.amqp.rabbit.core.RabbitTemplate
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Lazy

@RestResource
//@RestResource
class ServiceScmWebhookResourceImpl @Autowired constructor(
private val pipelineBuildWebhookService: PipelineBuildWebhookService,
private val rabbitTemplate: RabbitTemplate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ import org.springframework.core.Ordered
@Configuration
@ConditionalOnWebApplication
@AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE)
class PipelinePermConfiguration {
class PipelinePermConfiguration constructor(
val dslContext: DSLContext
){

@Bean
@ConditionalOnProperty(prefix = "auth", name = ["idProvider"], havingValue = "bk_login")
Expand All @@ -73,7 +75,7 @@ class PipelinePermConfiguration {
@Bean
@ConditionalOnProperty(prefix = "auth", name = ["idProvider"], havingValue = "sample")
fun mockPipelinePermissionService(
dslContext: DSLContext,

pipelineInfoDao: PipelineInfoDao,
authProjectApi: AuthProjectApi,
authResourceApi: AuthResourceApi,
Expand All @@ -91,7 +93,7 @@ class PipelinePermConfiguration {
@Bean
@ConditionalOnProperty(prefix = "auth", name = ["idProvider"], havingValue = "bk_login_v3")
fun v3pipelinePermissionService(
dslContext: DSLContext,

client: Client,
redisOperation: RedisOperation,
pipelineInfoDao: PipelineInfoDao,
Expand All @@ -115,7 +117,7 @@ class PipelinePermConfiguration {
fun githubStreamPipelinePermissionService(
client: Client,
pipelineInfoDao: PipelineInfoDao,
dslContext: DSLContext,

checkTokenService: ClientTokenService
): PipelinePermissionService = StreamPipelinePermissionServiceImpl(
client = client,
Expand All @@ -129,7 +131,7 @@ class PipelinePermConfiguration {
fun gitlabStreamPipelinePermissionService(
client: Client,
pipelineInfoDao: PipelineInfoDao,
dslContext: DSLContext,

checkTokenService: ClientTokenService
): PipelinePermissionService = StreamPipelinePermissionServiceImpl(
client = client,
Expand All @@ -144,7 +146,7 @@ class PipelinePermConfiguration {
authPermissionApi: AuthPermissionApi,
authProjectApi: AuthProjectApi,
pipelineAuthServiceCode: PipelineAuthServiceCode,
dslContext: DSLContext,

pipelineInfoDao: PipelineInfoDao,
pipelineViewGroupService: PipelineViewGroupService,
authResourceApi: AuthResourceApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ import com.tencent.devops.repository.utils.RepositoryUtils
import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware
import org.springframework.stereotype.Service

@Suppress("ALL")
@Service
abstract class PipelineBuildWebhookService : ApplicationContextAware {

override fun setApplicationContext(applicationContext: ApplicationContext) {
Expand All @@ -95,7 +97,6 @@ abstract class PipelineBuildWebhookService : ApplicationContextAware {
gitWebhookUnlockDispatcher = applicationContext.getBean(GitWebhookUnlockDispatcher::class.java)
pipelineWebHookQueueService = applicationContext.getBean(PipelineWebHookQueueService::class.java)
buildLogPrinter = applicationContext.getBean(BuildLogPrinter::class.java)
pipelinebuildWebhookService = applicationContext.getBean(PipelineBuildWebhookService::class.java)
pipelineBuildCommitService = applicationContext.getBean(PipelineBuildCommitService::class.java)
webhookBuildParameterService = applicationContext.getBean(WebhookBuildParameterService::class.java)
}
Expand All @@ -110,7 +111,6 @@ abstract class PipelineBuildWebhookService : ApplicationContextAware {
lateinit var gitWebhookUnlockDispatcher: GitWebhookUnlockDispatcher
lateinit var pipelineWebHookQueueService: PipelineWebHookQueueService
lateinit var buildLogPrinter: BuildLogPrinter
lateinit var pipelinebuildWebhookService: PipelineBuildWebhookService // 给AOP调用
lateinit var pipelineBuildCommitService: PipelineBuildCommitService
lateinit var webhookBuildParameterService: WebhookBuildParameterService
private val logger = LoggerFactory.getLogger(PipelineBuildWebhookService::class.java)
Expand Down Expand Up @@ -265,13 +265,13 @@ abstract class PipelineBuildWebhookService : ApplicationContextAware {
return@outside
}

if (pipelinebuildWebhookService.webhookTriggerPipelineBuild(
/*if (pipelinebuildWebhookService.webhookTriggerPipelineBuild(
projectId = projectId,
pipelineId = pipelineId,
codeRepositoryType = codeRepositoryType,
matcher = matcher
)
) return@outside
) return@outside*/
} catch (e: Throwable) {
logger.warn("[$pipelineId]|webhookTriggerPipelineBuild fail: $e", e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ class SamplePipelineBuildWebhookService : PipelineBuildWebhookService() {
)
}

@BkTimed // 要aop生效必须在子类上拦截
/* @BkTimed // 要aop生效必须在子类上拦截
override fun webhookTriggerPipelineBuild(
projectId: String,
pipelineId: String,
codeRepositoryType: String,
matcher: ScmWebhookMatcher
): Boolean {
return super.webhookTriggerPipelineBuild(projectId, pipelineId, codeRepositoryType, matcher)
}
}*/
}

0 comments on commit 4ae4fc4

Please sign in to comment.