Customizing project templates (in terms of gradle)

Could it be possible to put e.g. repository configuration for dependency resolution and publishing into seperate files and make the use of the gradle wrapper optional?

This is why. We are developing in a network environment which is not connected to the internet. After creating projects with the Jmix wizards lots of errors encounter because we have to make a certain amount of changes.

The gradle wrapper script created by the wizard tries to download a gradle instance from the internet. We are using a local gradle installation (currently 7.3.3) and need to specify using that installation manually.

For build script resolution we have to add a section to the settings.gradle file:

pluginManagement {
  repositories {
    mavenLocal()
    maven {
      /* proxy gradle plugin repository */
      url 'https://nexus.company.com/content/repositories/gradle-plugins'
    }
  }
}

For code artifact dependency resolution we are using a repository proxy application for maven central and the jmix repository:

repositories {
  mavenLocal()
  maven {
    url 'https://maven.company.com'
  }
  maven {
    /* proxy maven central */
    url 'https://nexus.company.com/content/repositories/central'
    content {
      excludeGroupByRegex "com\\.company.*"
    }
  }
  maven {
    /* proxy jmix repositories */
    url 'https://nexus.company.com/content/repositories/jmix'
    content {
      excludeGroupByRegex "com\\.company.*"
    }
  }
}

Could it be possible to introduce something that saves us doing the for every single project.

This is also a task when downloading sample projects to reproduce issues or trying suggested example code.

You can create and use your own set of templates published on your own artifact repository.

Studio loads the list of templates from the first repository in the list which has the io.jmix.templates.studio:jmix-studio-templates artefact. Normally it’s a set of templates built by us from the https://github.com/Haulmont/jmix-templates repo for each Jmix release. But you can clone this repo, add your own templates and publish them to your private artefact repository.

For example:

cd jmix-templates
./gradlew publish -PjmixUploadUrl=http://localhost:8081/repository/maven-snapshots/ -PjmixUploadUser=admin -PjmixUploadPassword=admin

Then when creating a new project in Studio, select a custom configuration and add your repository to the start of the list, for example:
image

After that, you should see your templates on the next step of the wizard. If not, restart the IDE once (your repository will remain in the list).

Ok, I will think about that. Two considerations about that…

  1. Will still have to synchronize changes on your original templates on each release
  2. If we might commit and push some projects to a (more) public source code repository and want to invite developers who are developing in another (regular Internet environment), this approach does not work straight forward

Your concerns are absolutely valid.

We’ve recently filed an issue for improvement in this area: Ability to create custom project template : JST-2553. Will try to do it in the next feature release.

2 Likes