'gradle'에 해당되는 글 17건

  1. 2022.03.15 [Gradle] build.gradle 에서 maven insecure protocol 설정
  2. 2022.01.24 [Gradle] configurations 를 이용한 log4j dependency 반영
  3. 2021.09.15 [Gradle] 6.x 에서 7.x 로 넘어 오면서 runtime, compile.
  4. 2021.07.15 [JUnit] intellij 에서 junit 테스트 코드 작성 시 경험 하는 에러.
  5. 2021.02.03 [Intellij] 가끔 Dependency Lib 빨갱이 발생
  6. 2021.01.27 [Gradle] Dependency Lib 이상 할 때.
  7. 2020.04.20 [Gradle] Task Tutorial
  8. 2020.04.17 [Gradle] Task Zip
  9. 2018.07.04 [Jenkins] Gradle 을 이용한 submodule update 이슈
  10. 2018.05.02 [Spring Framework] SpringMVC + Gradle 템플릿 + Tomcat 연동

[Gradle] build.gradle 에서 maven insecure protocol 설정

ITWeb/개발일반 2022. 3. 15. 12:39

maven. uri 설정 시 https 가 아닌 http 를 사용 할 경우 gradle 7.x 에서는 아래 설정을 추가해 주면 됩니다.

 

repositories {
	mavenCentral()
    
    maven {
    	url = uri("http://nexus.xxxxx.com/repository/snapshots")
        allowInsecureProtocol = true
    }
    
    maven {
    	url = uri("http://nexus.xxxxx.com/repository/public")
        allowInsecureProtocol = true
    }
}

 

:

[Gradle] configurations 를 이용한 log4j dependency 반영

ITWeb/개발일반 2022. 1. 24. 11:40

최근에 발생한 log4j 보안 이슈로 인해서 patch 작업이 필요 했었는데요.

build.gradle 에서 configurations 를 이용해서 쉽게 적용 할 수 있는 방법인데 기억하기 위해 이것도 기록해 봅니다.

 

관련 보안 내용은 아래 링크 참고 하시면 됩니다.

Log4j – Apache Log4j Security Vulnerabilities

 

Log4j – Apache Log4j Security Vulnerabilities

<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apa

logging.apache.org

build.gradle)

configuration {
  all {
  	resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    	if ( details.requested.group == 'org.apache.logging.log4j' ) {
        	details.useVersion '2.17.1'
        }
    }
  }
  
  compileOnly {
    extendsFrom annotationProccessor
  }
}

 

:

[Gradle] 6.x 에서 7.x 로 넘어 오면서 runtime, compile.

ITWeb/개발일반 2021. 9. 15. 17:51

아래와 같이 변경 해서 사용 하면 됩니다.

- Gradle 6.x 에서 Gradle 7.x 로 넘어 오면서 runtime, compile.
[6.x]
task copyDependencies(type: Copy) {
  into "$buildDir/libs/deps"
  from configurations.runtime
}

[7.x]
task copyDependencies(type: Copy) {
  into "$buildDir/libs/deps"
  from configurations.runtimeClasspath
}

[6.x]
jar {
  manifest {
    attributes 'Main-Class': 'Main.class',
        'Class-Path': configurations.compile.files.collect { "deps/$it.name" }.join(' ')
  }

  archiveName 'dictionary.jar'
  from {
    configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
  }
}

[7.x]
jar {
  manifest {
    attributes 'Main-Class': 'Main.class',
        'Class-Path': configurations.compileClasspath.files.collect { "deps/$it.name" }.join(' ')
  }

  archiveName 'dictionary.jar'
}

 

:

[JUnit] intellij 에서 junit 테스트 코드 작성 시 경험 하는 에러.

ITWeb/개발일반 2021. 7. 15. 09:42

아래와 같은 에러를 경험 하셨다면 intellij 에서의 설정을 변경해 주시면 됩니다.

 

Execution failed for task ':test'.
> No tests found for given includes: [com.kakaopay.stark.pipeline.indexer.PropertiesTest.testMultilineProperty](filter.includeTestsMatching)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

 

IntelliJ -> Preferences -> Build,Execution,Deployment -> Build Tools -> Gradle

Gradle projects -> Run tests using -> Gradle (Default) 를 Intellij IDEA 로 바꾸시면 됩니다.

:

[Intellij] 가끔 Dependency Lib 빨갱이 발생

ITWeb/개발일반 2021. 2. 3. 10:55

Intellij 를 이용해서 개발을 진행 하다 보면 가끔 dependency lib 설정과 다운로드가 정상적으로 되어 있음에도 불구 하고 관련 클래스를 못찾거나 lib 을 못찾을 때가 있습니다.

그럴 때는 그냥 리셋 한번 하는게 맘 편할 때가 있습니다.

최근 제가 두 번이나 발생을 해서 기록해 봅니다.

 

[Gradle]
https://docs.gradle.org/current/userguide/what_is_gradle.html

.gradle 폴더 안에 들어 있는 것들 다 삭제 합니다.

 

[Maven]
https://maven.apache.org/what-is-maven.html

.m2 폴더 안에 들어 있는 것들 다 삭제 합니다.

 

:

[Gradle] Dependency Lib 이상 할 때.

ITWeb/개발일반 2021. 1. 27. 14:25

가끔 제 맥북만 이상 할 때가 있습니다.

그래서 간혹 dependency 오류가 발생을 하게 되면..

  1. cd ~/.gradle 에 들어가서 rm -rf * 로 받아 놓은거 삭제 합니다.
  2. 주의 해서 rm -rf * 하세요… ㅋㅋㅋ
  3. 해당 브랜치에 가서 git stash; git pull 해서 최신 코드로 유지를 시켜 주세요.
  4. gradle refresh 해주시면 됩니다.
:

[Gradle] Task Tutorial

ITWeb/개발일반 2020. 4. 20. 10:34

Gradle 을 이용한 build.gradle 작성 시 튜토리얼을 한번 보고 해보면 좋습니다.

 

[공식문서]

https://docs.gradle.org/current/userguide/tutorial_using_tasks.html

https://docs.gradle.org/current/dsl/org.gradle.api.Task.html

 

Task 의 실행 단계는 

- Task 본문의 Configuration

- doFirst

- doLast

단계로 실행 됩니다.

 

이 실행 단계를 이해 하기 위해서는 아래 문서를 참고 하세요.

 

[공식문서]

https://docs.gradle.org/current/userguide/build_lifecycle.html

Initialization

Gradle supports single and multi-project builds. 
During the initialization phase, Gradle determines 
which projects are going to take part in the build, 
and creates a Project instance for each of these projects.

Configuration

During this phase the project objects are configured. 
The build scripts of all projects which are part of the build are executed.

Execution

Gradle determines the subset of the tasks, 
created and configured during the configuration phase, to be executed. 
The subset is determined by the task name arguments passed to the gradle command 
and the current directory. 
Gradle then executes each of the selected tasks.

settings.gradle > build.gradle > task configured > task internal configuration > task

 

더불어서 task 가 실행 되지 않는 경우가 있는데 이 경우는 아래의 경우 실행 되지 않습니다.

 

- SKIPPED

Task did not execute its actions.

- NO-SOURCE

Task did not need to execute its actions.

  • Task has inputs and outputs, but no sources. For example, source files are .java files for JavaCompile.

:

[Gradle] Task Zip

ITWeb/개발일반 2020. 4. 17. 10:13

참고문서)

https://docs.gradle.org/current/userguide/working_with_files.html#sec:creating_archives_examplel

 

예제) build.gradle

plugins {
  id 'base'
}

def buildNumber = System.getenv('BUILD_NUMBER')
version = "0.0.${buildNumber}"

task packageDistribution(type: Zip) {
  archiveFileName = "${project.name}-${project.version}.zip"
  destinationDirectory = file("$buildDir/dist")

  from 'docker-compose', 'scripts'
}

 

:

[Jenkins] Gradle 을 이용한 submodule update 이슈

ITWeb/개발일반 2018. 7. 4. 07:53

Jenkins 에서 Gradle 을 이용한 multi project(submodule) build 시 참고사항

젠킨스 소스 관리영역에서 Additional Behaviours 설정을 추가 해줘야 합니다.


- Advanced sub-modules behaviours

여기서 총 세 가지 항목을 선택 하게 됩니다.


- Recursively update submodules

이 설정은 --recursive 옵션을 사용합니다.


- Update tracking submodules to tip of branch

이 설정은 --remote 옵션을 사용합니다.


- Use credentials from default remote of parent repository

이 설정은 parent project 의 credential 을 사용 한다는 의미 입니다. 


여기서 제가 경험한 문제는 submodule 이 업데이트 되지 않는 문제였습니다.

intellij 에서 Project Update 기능과 비슷하다고 보시면 될 것 같은데요.


이 와 같은 기능을 적용하기 위해서는 위 2번째 옵션을 선택해줘야 합니다.


- Update tracking submodules to tip of branch

이 옵션의 의미는 submodules 의 변경된 내용을 업데이트 하기 위한 것입니다.


참고문서)

https://git-scm.com/docs/git-submodule#git-submodule---remote



:

[Spring Framework] SpringMVC + Gradle 템플릿 + Tomcat 연동

ITWeb/개발일반 2018. 5. 2. 18:33

매니저 역할을 오래 하다 보면 개발 감각이 떨어 지는건 어쩔수 없는 일인 것 같습니다.

SpringMVC 를 이용한 기본 웹 개발도 이제는 거북이 수준이 되어 가고 있는 것 같아 잊지 않기 위해 기록해 봅니다.


요즘 워낙 좋은 Tool, IDE 들이 많이 나와 있고. Git 검색만 해봐도 찾던 소스가 너무나도 많이 나옵니다.

아래는 Intellij community 버전을 이용해서 웹프로젝트 템플릿을 생성하는 예제 입니다.


각 단계별 코드별 설명은 작성 하지 않았습니다.

이유는 여긴 제가 그냥 혼자 기록하고 공부하는 공간이고, 누구를 가르치기에 너무 많은 무림고수 들이 계셔서 어쭙잖은 설명은 그냥 아래 레퍼런스로 대신 합니다.


References)

https://github.com/HowookJeong/springmvc-gradle-template

https://tomcat.apache.org/tomcat-9.0-doc/config/context.html

https://docs.spring.io/spring/docs/4.3.16.RELEASE/spring-framework-reference/htmlsingle/#spring-web


Step 1)

Intellij 를 실행 하고 매뉴에서 아래와 같이 선택을 합니다.


File -> New -> Project -> Gradle -> Java -> Next


GroupId -> org.project.web

ArtifactId -> springmvc-gradle-template

Next


Step 2)

SpringMVC Framework 틀을 만들기 위해 필요한 폴더와 파일들을 아래와 같이 생성을 합니다.


2-1) Community 버전으로는 gradle webapp 추가가 안되기 때문에 별도로 생성 합니다.

Make webapp directory

src/main/webapp


2-2) Make WEB-INF directory

src/main/webapps/WEB-INF

web.xml

dispatcher-servlet.xml


2-3) jsp template 사용을 위해서 WEB-INF 아래 jsp 폴더를 생성 합니다.

Make jsp directory

src/main/webapps/WEB-INF/jsp


2-4) Resource 구성을 합니다.

Make resources directory

src/main/resources/beans

bo-bean.xml

dao-bean.xml

src/main/resources/context

applicationContext.xml

applicationContext-mybatis.xml

src/main/resources/mybatis

config.xml

jdbc.properties

src/main/resources/sql

example.xml

log4j.xml


2-5) Package 구성을 합니다.

Make packages

org.project.web.bo

org.project.web.controllor

org.project.web.dao

org.project.web.model


여기까지 하셨으면 기본 empty project 생성은 끝났습니다.

이제 필요한 코드와 설정을 해보도록 하겠습니다.


Step 3)

이제 필요한 코드들을 생성해 보도록 하겠습니다.


3-1) web.xml 설정하기



3-2) dispatcher-servlet.xml 설정하기



3-3) log4j.xml 설정하기



3-4) mybatis/config.xml 설정하기



3-5) mybatis/jdbc.properties 설정하기



3-6) build.gradle 설정하기



이제 application 구현을 위한 코드 생성을 해보겠습니다.


3-7) controller/ExampleController


3-8) bo/ExampleBO


3-9) bo/ExampleBOImpl


3-10) dao/ExampleDAO


3-11dao/ExampleDAOImpl


3-12) model/ExampleModel



코드 구현을 했으니 이제 resources 설정을 하도록 하겠습니다.


3-13) beans/bo-bean.xml


3-14) beans/dao-bean.xml


3-15) context/applicationContext.xml


3-16) context/applicationContext-mybatis.xml


3-17) sql/example.xml


화면 구성을 위한 데코레이션으로 jsp 코드를 작성해 보겠습니다.


3-18) WEB-INF/jsp/exampleView.jsp


: