Mercurial > hg > tc-symbol-server
diff agent/src/jetbrains/buildServer/symbols/SrcSrvStreamBuilder.java @ 25:f4e0050e2a2f
resolve server url from config parameter
author | Evgeniy.Koshkin |
---|---|
date | Tue, 06 Aug 2013 14:18:09 +0400 |
parents | agent/src/jetbrains/buildServer/symbols/SrcSrvStreamProvider.java@9cbdbfed44f4 |
children | 6ac3c2491e1a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/src/jetbrains/buildServer/symbols/SrcSrvStreamBuilder.java Tue Aug 06 14:18:09 2013 +0400 @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package jetbrains.buildServer.symbols; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Collection; + +/** + * @author Evgeniy.Koshkin + */ +public class SrcSrvStreamBuilder { + + private final FileUrlProvider myUrlProvider; + + public SrcSrvStreamBuilder(final FileUrlProvider urlProvider) { + myUrlProvider = urlProvider; + } + + public void dumpStreamToFile(File targetFile, Collection<File> sourceFiles) throws IOException { + final FileWriter fileWriter = new FileWriter(targetFile.getPath(), true); + + try { + fileWriter.write("SRCSRV: ini ------------------------------------------------\r\n"); + fileWriter.write("VERSION=3\r\n"); + fileWriter.write("INDEXVERSION=2\r\n"); + fileWriter.write("VERCTRL=http\r\n"); + fileWriter.write("SRCSRV: variables ------------------------------------------\r\n"); + fileWriter.write("SRCSRVVERCTRL=http\r\n"); + fileWriter.write(String.format("HTTP_ALIAS=%s\r\n", myUrlProvider.getHttpAlias())); + fileWriter.write("HTTP_EXTRACT_TARGET=%HTTP_ALIAS%/%var2%\r\n"); + fileWriter.write("SRCSRVTRG=%HTTP_EXTRACT_TARGET%\r\n"); + fileWriter.write("SRCSRVCMD=\r\n"); + fileWriter.write("SRCSRV: source files ------------------------------------------\r\n"); + for(File sourceFile : sourceFiles){ + final String sourceFileCanonical = sourceFile.getCanonicalPath(); + fileWriter.write(String.format("%s*%s\r\n", sourceFileCanonical, myUrlProvider.getFileUrl(sourceFileCanonical))); + } + fileWriter.write("SRCSRV: end ------------------------------------------------"); + } + finally { + fileWriter.close(); + } + } +}