import java.io.File;
import java.util.Collection;
import java.util.List;
import org.apache.commons.io.FileUtils;

/**
 * 특정 디렉토리 하위의, 특정 확장자 파일에 대한 처리
 *   - 2번째 줄에 trimDirectiveWhitespaces 처리를 위한 내용 추가
 * 
 * @author 엄승하
 */
public class JspAddTrimWhitespaceTag {
     public static void main(String[] args) throws Exception {
          //jsp파일을 찾기 시작할 디렉토리
          String startDirPath = "파일을 찾기 시작할 디렉토리 경로";
          //파일 확장자 지정
          String[] ext = {"jsp"};
          //해당 파일들을 찾아서 컬렉션에 담음(recursive)
          Collection<File> jspFileList = FileUtils.listFiles(new File(startDirPath), ext, true);
          System.out.println(String.format("총 %s개", jspFileList.size()));
          String addStr = "<%@ page trimDirectiveWhitespaces=\"true\" %>"; //파일에 추가할 내용 : JSTL의 html변경 후 남은 whitespace를 없애는 처리
          for (File jspFile : jspFileList) {
               //System.out.println(file.getAbsolutePath());
              List<String> fileContents = FileUtils.readLines(jspFile, "UTF-8");
              fileContents.add(1, addStr); //2번째줄에 추가할 문자를 컨텐츠 내용에 추가
              FileUtils.writeLines(jspFile, fileContents); //해당 파일에 쓰기
              fileContents = null; //빠른 GC처리
          }
          System.out.println("====  끝  ====");
     }
}
  1. SVN


  1. SVN 커넥터(Repositories 추가시 설치 창이 뜸)



  1. 인코딩셋 셋팅(웹 개발관련)


4. 에디터에 라인 번호 표시



  1. 톰캣서버 설정






2016-05-31 기준
설치한 플러그린 리스트




import java.io.IOException;
import java.net.URI;

import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthCache;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

/**
 * Jenkins JOB 실행하는 프로그램
 *  - httpclient 4.3.x 이상 필요
 *  - 참고 : https://wiki.jenkins- ci.org/display/JENKINS/Authenticating+scripted+clients
 *
 * @author 엄승하
 */
public class TestCallJenkinsJob {

     public String scrape(String urlString, String username, String password ) throws ClientProtocolException, IOException {

          URI uri = URI.create( urlString);
          HttpHost host = new HttpHost(uri.getHost(), uri.getPort(), uri .getScheme());
          CredentialsProvider credsProvider = new BasicCredentialsProvider();
           credsProvider.setCredentials(new AuthScope(uri.getHost(), uri .getPort()), new UsernamePasswordCredentials(username , password));

           // Create AuthCache instance
          AuthCache authCache = new BasicAuthCache();

           // Generate BASIC scheme object and add it to the local auth cache
          BasicScheme basicAuth = new BasicScheme();
           authCache.put(host , basicAuth);
          CloseableHttpClient httpClient = HttpClients.custom().setDefaultCredentialsProvider( credsProvider).build();
          HttpGet httpGet = new HttpGet(uri);

           // Add AuthCache to the execution context
          HttpClientContext localContext = HttpClientContext.create();
           localContext.setAuthCache(authCache );

          HttpResponse response = httpClient .execute(host, httpGet, localContext );

           return EntityUtils.toString(response.getEntity());

     }

     public static void main(String[] args) {

          String jobUrl = "JOB URL(토큰정보 포함)" ;
          String userNm = "계정ID" ;
          String pwd = "계정 암호" ;

           try {

              String rslt = new TestCallJenkinsJob().scrape(jobUrl , userNm, pwd);
              System. out.println("rslt: " + rslt);

          } catch (IOException e ) {
               e.printStackTrace();
          }
     }

}


+ Recent posts