'maven'에 해당되는 글 16건

  1. 2022.03.15 [Gradle] build.gradle 에서 maven insecure protocol 설정
  2. 2021.02.03 [Intellij] 가끔 Dependency Lib 빨갱이 발생
  3. 2017.01.17 [Gradle] maven to gradle project 변환
  4. 2017.01.09 [Gradle] Gradle project 맛보기.
  5. 2016.10.07 [Maven] maven-replacer-plugin 사용하기.
  6. 2016.03.09 [Maven] 간단 Profile을 이용한 서비스 환경 구성
  7. 2016.02.29 [Maven] maven 프로젝트 naming convention - group id, artifact id, version ...
  8. 2015.12.05 [JAVA] executable jar 생성 시 pom.xml build 설정.
  9. 2015.09.22 [Maven] Executable jar + Assembly 를 이용한 tar 묶기.
  10. 2015.03.18 [Intellij] maven 프로젝트 enable(?) 하기

[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
    }
}

 

:

[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] maven to gradle project 변환

ITWeb/개발일반 2017. 1. 17. 12:35

Maven 프로젝트를 Gradle 프로젝트로 간단하게 변환하기 입니다.


$ gradle init --type pom


:

[Gradle] Gradle project 맛보기.

ITWeb/개발일반 2017. 1. 9. 13:46

Intellij 를 이용한 gradle project 를 생성하는 아주 초보적인 내용입니다.

개인적인 생각으로는 single project 이고 maven 에 익숙하시면 그냥 maven project 로 개발 하시는게 편하실 수 있습니다.


Step 0)

- Gradle 설치가 되어 있어야 합니다.

- Java 설치가 되어 있어야 합니다.

- Path 설정이 되어 있어야 합니다.


Step 1)

New -> Project -> Gradle 선택을 하시면 됩니다.


Step 2)

maven project 생성 할 때와 동일하게 GroupId, ArtifactId, Version 정보를 등록 하면 됩니다.


Next 버튼을 누르고 누르고 나면 기본 Gradle Project 가 생성이 됩니다.


Step 3) build.gradle & settings.gradle

기본적인 빌드 환경과 정보들을 작성 하게 됩니다.

maven 의 pom.xml 과 비슷하다고 보시면 될 것 같습니다.


Step 4) module 추가하기

해당 프로젝트에서 new -> module 하시면 됩니다.

동일하게 gradle project 으로 해서 추가했습니다.


Step 5) 기본 java application directory 생성

src/main/java

src/main/resources

src/test/java

src/test/resources


Step 6) Java main class 생성

public class HelloWorld {

public static void main (String[] args) {
System.out.println("Hello World!!");
}
}


Step 7) Build & Run

$ gradle build


$ java -jar ./helloworld/build/libs/helloworld-1.0-SNAPSHOT.jar HelloWorld

./helloworld/build/libs/helloworld-1.0-SNAPSHOT.jar에 기본 Manifest 속성이 없습니다.


# manifest 속성을 선언 안해서 그렇습니다.
해당 프로젝트의 build.gradle 에 선언 하면 됩니다.
excutable jar 생성 하는 거랑 같은 거라고 보시면 됩니다.
jar {
manifest {
attributes 'Main-Class': 'org.jjeong93.hello.HelloWorld'
}
}

$ java -jar ./helloworld/build/libs/helloworld-1.0-SNAPSHOT.jar HelloWorld

Hello World!!


일반적인 Java application 만드는 걸 예제로 보여 드렸습니다.
저는 기존 maven project 를 gradle multi project 로 마이그레이션 하려고 합니다.
dependency 설정 하는 번거로움이 좀 있기는 하지만 마이그레이션 방법을 제공 하고 있으니 참고 하면 될 것 같습니다.

[참고문서]


:

[Maven] maven-replacer-plugin 사용하기.

ITWeb/개발일반 2016. 10. 7. 14:54

간혹 필요할때가 있어서 포스팅 합니다.

maven project 를 사용하면서 소스코드에서 특정 변수에 대한 치환을 하고 싶을 때 사용하시면 됩니다.

최근에 javascript 파일에 대한 v=@_FINGERPRINT 정보를 추가 하기 위해 사용했습니다.


[참고문서]

https://github.com/beiliubei/maven-replacer-plugin/wiki/Usage-Guide

https://gist.github.com/ekcode/a338ec66c81bcaca1d9d


[pom.xml]

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>front-web-service-${version}</warName>
</configuration>
<executions>
<execution>
<id>prepare-war</id>
<phase>prepare-package</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<filesToInclude>
**/layout.jsp
</filesToInclude>
<replacements>
<replacement>
<token>@_FINGERPRINT</token>
<value>${version}</value>
</replacement>
</replacements>
</configuration>
</plugin>


역시 구글링 하면 많은 예제 코드들이 나옵니다.

:

[Maven] 간단 Profile을 이용한 서비스 환경 구성

ITWeb/개발일반 2016. 3. 9. 10:32

개발과 운영 또는 test, qa, stage 등 다양한 개발 및 서비스 환경이 있을 수 있습니다.

그렇다 보니 RDBMS를 사용하는 경우 연결 정보를 다르게 가져가야 하는데요.

이럴경우 maven profile 기능을 이용해서 구성이 가능 합니다.

기억력에 의존할 나이가 넘었으므로 기록해 보겠습니다.

(구글링 해보시면 자세하게 정리된 문서 많이 나와 있습니다.)


참고문서)

http://maven.apache.org/guides/introduction/introduction-to-profiles.html


저는 간단하게 development 환경과 production 환경 두 가지만 설정 하도록 하겠습니다.


pom.xml 설정)

<profiles>
<profile>
<id>development</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<env>development</env>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<env>production</env>
</properties>
</profile>
</profiles>

<build>
<resources>
<resource>
<directory>src/main/resources/${env}</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources/${env}</directory>
</testResource>
</testResources>
</build>


빌드 옵션)

$ mvn clean package -P development


디렉토리 구성)

src/main/resources/development

src/main/resources/production


※ src/test 는 여기에 구성하지 않았습니다. ^^;


:

[Maven] maven 프로젝트 naming convention - group id, artifact id, version ...

ITWeb/검색일반 2016. 2. 29. 16:32

이것도 매번 기억 못해서 찾아 보던 거라 그냥 기록해 봅니다.

기록이라기 보다는 그냥 스크랩이 맞는 것 같내요.


원본 링크)


원본)

  • groupId will identify your project uniquely across all projects, so we need to enforce a naming schema. It has to follow the package name rules, what means that has to be at least as a domain name you control, and you can create as many subgroups as you want. Look at More information about package names.

    eg. org.apache.maven, org.apache.commons

    A good way to determine the granularity of the groupId is to use the project structure. That is, if the current project is a multiple module project, it should append a new identifier to the parent's groupId.

    eg. org.apache.maven, org.apache.maven.plugins, org.apache.maven.reporting

  • artifactId is the name of the jar without version. If you created it then you can choose whatever name you want with lowercase letters and no strange symbols. If it's a third party jar you have to take the name of the jar as it's distributed.

    eg. maven, commons-math

  • version if you distribute it then you can choose any typical version with numbers and dots (1.0, 1.1, 1.0.1, ...). Don't use dates as they are usually associated with SNAPSHOT (nightly) builds. If it's a third party artifact, you have to use their version number whatever it is, and as strange as it can look.

    eg. 2.0, 2.0.1, 1.3.1


:

[JAVA] executable jar 생성 시 pom.xml build 설정.

ITWeb/개발일반 2015. 12. 5. 20:40

맨날 잊어버리기 때문에 별거 아니지만 그냥 기록 합니다.


아래 설정은 executable jar 를 만들때 필요한 dependency jar 와 classpath 를 함께 구성해 주기 위해서 사용을 합니다.

자세한 내용은 링크 참고 하시면 됩니다.


[Apache Maven Archiver Examples Classpath]


[build property example]

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>compile</includeScope>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<index>false</index>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>MainClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- Ignore/Execute plugin execution -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<!-- copy-dependency plugin -->
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>


:

[Maven] Executable jar + Assembly 를 이용한 tar 묶기.

ITWeb/개발일반 2015. 9. 22. 12:29

main 함수 만들고 executable jar로 만들기 위해서 일반적인 패키징 작업중 하나 입니다.

그냥 또 기억 못할까봐 정리해 봅니다.

기본적인 내용이 자세한 내용과 활용은 아래 링크 참고하세요.


Ref.

https://maven.apache.org/plugins-archives/maven-assembly-plugin-2.5.4/

https://maven.apache.org/plugins/maven-assembly-plugin/assembly-mojo.html


[pom.xml 에 maven assembly plugin 추가 하기]

    <plugins>

...

      <plugin>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-jar-plugin</artifactId>

        <version>2.4</version>

        <configuration>

          <archive>

            <index>false</index>

            <manifest>

              <addClasspath>true</addClasspath>

              <mainClass>${MAINCLASS}</mainClass>

            </manifest>

          </archive>

        </configuration>

      </plugin>

      <plugin>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-assembly-plugin</artifactId>

        <version>2.4</version>

        <configuration>

          <descriptors>

            <descriptor>src/main/assemblies/package.xml</descriptor>

          </descriptors>

          <finalName>${project.name}</finalName>

          <appendAssemblyId>false</appendAssemblyId>

        </configuration>

        <executions>

          <execution>

            <id>tarball</id>

            <phase>package</phase>

            <goals>

              <goal>single</goal>

            </goals>

          </execution>

        </executions>

      </plugin>

...

    </plugins>


[assembly 생성하기]

- src/main/assemblies/package.xml

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"

          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.

1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

  <id>tarball</id>

  <formats>

    <format>tar</format>

  </formats>

  <fileSets>

    <fileSet>

      <directory>${project.basedir}</directory>

      <outputDirectory>/</outputDirectory>

      <includes>

        <include>bin/*.sh</include>

        <include>lib/sigar/*.so</include>

        <include>lib/sigar/*.dylib</include>

        <include>lib/sigar/*.dll</include>

        <include>lib/sigar/*.lib</include>

      </includes>

    </fileSet>

  </fileSets>

</assembly>


참 쉽죠!!

이렇게 만들어서 생성을 하게 되면 최종 tarball 은 아래와 같은 형태로 만들어 집니다.


${project.name}.tar

- 여기서 <finalName>과 <appendAssemblyId> 설정에 따라 finalName으로 이름이 적용 되게 됩니다.

:

[Intellij] maven 프로젝트 enable(?) 하기

ITWeb/개발일반 2015. 3. 18. 10:53

eclipse를 사용하다 요즘 apache ambari, tajo 관련 코드 및 개발 진행이 필요해 intellij로 넘어 가 볼까 하는데..

영 낯설다.. 


일단 maven project를 많이 사용하니 이것 부터 해보려 하는데.. 

eclipse에서 잘 되던 maven project를 intellij로 import 해서 test code를 일단 실행해 봤다.

뜨악~ 그냥 일단 빨갱이들이.. 쭈욱~~~~


test code도 실행이 안된다.

뭐 당연한 이야기.. ㅋㅋ


그럼 내가 뭘 해줘야 하지???



보이시죠??

해당 프로젝트에서 

Maven -> Generate Sources and Update Folders 

Maven -> Reimport

를 해주시면 됩니다.


이제 intellij도 함 사용해 보지요.

: