Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta/Extracted common code to build module repository #18

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package org.mps_cli.gradle.plugin

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.mps_cli.model.SRepository
import org.mps_cli.model.builder.SLanguageBuilder
import org.mps_cli.model.builder.SModulesRepositoryBuilder

abstract class AbstractDependenciesBuilderTask extends DefaultTask {
Expand All @@ -13,21 +13,19 @@ abstract class AbstractDependenciesBuilderTask extends DefaultTask {
@Input
List<String> sourcesDir;

@Internal
SRepository repository;

abstract List<Object> allEntities();
abstract List<Object> directDependencies(Object entity);

def buildEntityDependencies(Map<?, Set<?>> entity2AllUpstreamDependencies,
Map<?, Set<?>> entity2AllDownstreamDependencies) {
SLanguageBuilder.clear()
sourcesDir.each {
def dir = new File(it).getAbsoluteFile().canonicalPath
println("loading models from directory: " + dir)
builder.build(dir)
}
repository = builder.buildAll(sourcesDir)

for (Object entity : allEntities()) {
Set<Object> dependencies = [].toSet()
collectUpstreamDependencies(builder.repo, entity, dependencies)
collectUpstreamDependencies(repository, entity, dependencies)
entity2AllUpstreamDependencies[entity] = dependencies
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction
import org.mps_cli.model.SRepository
import org.mps_cli.model.builder.SLanguageBuilder
import org.mps_cli.model.builder.SModulesRepositoryBuilder

class ModelBuilderTask extends DefaultTask {
Expand All @@ -24,15 +23,8 @@ class ModelBuilderTask extends DefaultTask {
@TaskAction
def buildModel() {
def builder = new SModulesRepositoryBuilder()
SLanguageBuilder.clear()
sourcesDir.each {
def dir = new File(it).getAbsoluteFile().canonicalPath
println("loading models from directory: " + dir)
builder.build(dir)
}
//setProperty("repository", repository)
repository = builder.repo

repository = builder.buildAll(sourcesDir)
println("number of solutions: " + repository.modules.size)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ModelDependenciesBuilderTask extends AbstractDependenciesBuilderTask {

@Override
List<Object> allEntities() {
builder.repo.allModels()
repository.allModels()
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ModuleDependenciesBuilderTask extends AbstractDependenciesBuilderTask {

@Override
List<Object> allEntities() {
builder.repo.modules
repository.modules
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ class SModulesRepositoryBuilder {

def repo = new SRepository()

def buildAll(List<String> sourcesDir) {
SLanguageBuilder.clear()
sourcesDir.each {
def dir = Paths.get(it).toAbsolutePath().normalize().toString()
println("loading models from directory: " + dir)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to move this to a logger too? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mps-cli prints a lot of logs with println. This already used println before the change. It's those timings in particular, that took a lot of space, but didn't have much useful information

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright makes sense, thanks for the info!

build(dir)
}
repo
}

def build(String pathString) {
Date start = new Date()

Expand Down
Loading