Пример проекта с gradle и kotlin: https://github.com/cherepakhin/shop_kotlin
В проекте описано все, что нужно для сборки и deploy.
Примечания:
- Шпаргалка по Gradle
- Вывод gradle tasks:
./gradlew tasks
- Не найден plugin при сборке gradle
Добавить в начало (build.gradle млм build.gradle.kts):Это позволит искать плагин в центральном репозитории maven. Корневая секция (repositories {}) предназначена для dependencies , но не для plugins (buildscript{repositories{}})buildscript { repositories { mavenCentral() } }https://ru.stackoverflow.com/questions/1070668/Куда-обращается-gradle-за-org-springframework-bootbuildscript { repositories { mavenCentral() } }
Смена версии gradle для проекта:
./gradlew wrapper --gradle-version 7.4.2
https://tomgregory.com/gradle/how-to-update-gradle/ Запуск конкретного теста из консоли:
./gradlew test --tests "material.design.controller.CountryControllerMvcTest"
Тест для сервиса с авторизацией (ключевое @WithMockUser(value = "user")):
@RunWith(SpringRunner.class)
@WebMvcTest(CountryController.class)
public class CountryControllerMvcTest {
@Autowired
private MockMvc mockMvc;
@MockBean
CountryRepository repository;
@WithMockUser(value = "user")
@Test
public void getCountryOk() throws Exception {
List countries = new ArrayList<>();
Country country = new Country();
country.setId(1L);
countries.add(country);
when(repository.findAll()).thenReturn(countries);
this.mockMvc.perform(get("/country")).andDo(print()).andExpect(status().isOk());
}
...
Прогон только интеграционных тестов:
./gradlew test -Dtest.profile=integration
Для этого в build.gradle прописать:
test {
if (System.properties['test.profile'] != 'integration') {
exclude '**/*integrationTests*'
}