Skip to content

Commit

Permalink
build: Globally skip the server build (#2165)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCizmar authored Apr 12, 2024
1 parent 4122afe commit 64bc2b2
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 20 deletions.
6 changes: 0 additions & 6 deletions backend/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ bootJar {
manifest {
attributes('Implementation-Version': project.version)
}
onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
}

def unpackTarget = "build/dependency"
Expand All @@ -254,11 +253,6 @@ task addVersionFile(type: Task) {
}
}

project.tasks.findByName("compileKotlin").onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
project.tasks.findByName("bootBuildInfo").onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
project.tasks.findByName("compileJava").onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
project.tasks.findByName("bootJarMainClassName")?.onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }

sourceSets {
main.kotlin.srcDirs = ['src/main/kotlin', 'src/main/java']
test.kotlin.srcDirs = ['src/test/kotlin', 'src/test/java']
Expand Down
4 changes: 0 additions & 4 deletions backend/data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,6 @@ test {
maxHeapSize = "4096m"
}

project.tasks.findByName("compileKotlin").onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
project.tasks.findByName("compileJava").onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
project.tasks.findByName("bootJarMainClassName")?.onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }

sourceSets {
main.kotlin.srcDirs = ['src/main/kotlin', 'src/main/java']
test.kotlin.srcDirs = ['src/test/kotlin', 'src/test/java']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import io.tolgee.dtos.cacheable.UserAccountDto
import io.tolgee.service.organization.OrganizationService
import io.tolgee.service.project.ProjectService
import io.tolgee.service.security.UserAccountService
import jakarta.persistence.EntityManager
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Lazy
import org.springframework.context.event.EventListener
Expand All @@ -17,6 +18,7 @@ class BusinessEventReporter(
private val projectService: ProjectService,
private val organizationService: OrganizationService,
private val userAccountService: UserAccountService,
private val entityManager: EntityManager,
) {
@Lazy
@Autowired
Expand Down Expand Up @@ -109,12 +111,27 @@ class BusinessEventReporter(
val projectDto = data.projectDto ?: data.projectId?.let { projectService.findDto(it) }
val organizationId = data.organizationId ?: projectDto?.organizationOwnerId
val organizationName = data.organizationName ?: organizationId?.let { organizationService.get(it).name }
val userAccountDto = data.userAccountDto ?: data.userAccountId?.let { userAccountService.findDto(it) }
val userAccountId = data.userAccountId ?: findOwnerUserByOrganizationId(organizationId)
val userAccountDto = data.userAccountDto ?: userAccountId?.let { userAccountService.findDto(it) }
return data.copy(
projectDto = projectDto,
organizationId = organizationId,
organizationName = organizationName,
userAccountDto = userAccountDto,
)
}

private fun findOwnerUserByOrganizationId(organizationId: Long?): Long? {
organizationId ?: return null
return entityManager.createQuery(
"""
select u.id from UserAccount u
join u.organizationRoles orl on orl.organization.id = :organizationId
where orl.type = io.tolgee.model.enums.OrganizationRoleType.OWNER
order by u.id
limit 1
""",
Long::class.java,
).setParameter("organizationId", organizationId).resultList.firstOrNull()
}
}
4 changes: 0 additions & 4 deletions backend/development/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ dependencies {
implementation libs.kotlinCoroutines
}


project.tasks.findByName("compileKotlin").onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
project.tasks.findByName("compileJava").onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }

sourceSets {
main.kotlin.srcDirs = ['src/main/kotlin', 'src/main/java']
test.kotlin.srcDirs = ['src/test/kotlin', 'src/test/java']
Expand Down
4 changes: 0 additions & 4 deletions backend/testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ test {
maxHeapSize = "4096m"
}

project.tasks.findByName("compileKotlin").onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
project.tasks.findByName("compileJava").onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
project.tasks.findByName("bootJarMainClassName")?.onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }

sourceSets {
main.kotlin.srcDirs = ['src/main/kotlin', 'src/main/java']
test.kotlin.srcDirs = ['src/test/kotlin', 'src/test/java']
Expand Down
14 changes: 14 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ ktlint {
verbose = true
}

rootProject.subprojects {
afterEvaluate {
tasks.findByName("compileKotlin")?.onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
tasks.findByName("bootBuildInfo")?.onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
tasks.findByName("compileJava")?.onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
tasks.findByName("bootJarMainClassName")?.onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
tasks.findByName("jar")?.onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
tasks.findByName("bootJar")?.onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
tasks.findByName("classes")?.onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
tasks.findByName("classes")?.onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
tasks.findByName("compileTestKotlin")?.onlyIf { System.getenv("SKIP_SERVER_BUILD") != "true" }
}
}

subprojects {
task allDeps(type: DependencyReportTask) {}
ext['hibernate.version'] = hibernateVersion
Expand Down
1 change: 0 additions & 1 deletion ee/backend/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ dependencies {
liquibaseRuntime libs.liquibaseHibernate
liquibaseRuntime libs.kotlinReflect
liquibaseRuntime(project(":data"))

liquibaseRuntime sourceSets.main.output
liquibaseRuntime 'org.springframework.boot:spring-boot-starter-data-jpa'
}
Expand Down

0 comments on commit 64bc2b2

Please sign in to comment.