Mercurial > hg > tc-symbol-server
comparison agent/src/jetbrains/buildServer/symbols/SrcSrvStreamProvider.java @ 12:662a0be55de7
- source indexing works!
- few tests added
author | Evgeniy.Koshkin |
---|---|
date | Tue, 30 Jul 2013 22:10:30 +0400 |
parents | |
children | af87768a0724 |
comparison
equal
deleted
inserted
replaced
11:5fb218a7e574 | 12:662a0be55de7 |
---|---|
1 /* | |
2 * Copyright 2000-2013 JetBrains s.r.o. | |
3 * | |
4 * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 * you may not use this file except in compliance with the License. | |
6 * You may obtain a copy of the License at | |
7 * | |
8 * http://www.apache.org/licenses/LICENSE-2.0 | |
9 * | |
10 * Unless required by applicable law or agreed to in writing, software | |
11 * distributed under the License is distributed on an "AS IS" BASIS, | |
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 * See the License for the specific language governing permissions and | |
14 * limitations under the License. | |
15 */ | |
16 | |
17 package jetbrains.buildServer.symbols; | |
18 | |
19 import java.io.File; | |
20 import java.io.FileWriter; | |
21 import java.io.IOException; | |
22 import java.net.URI; | |
23 import java.util.Collection; | |
24 import java.util.Date; | |
25 | |
26 /** | |
27 * @author Evgeniy.Koshkin | |
28 */ | |
29 public class SrcSrvStreamProvider { | |
30 | |
31 private String myRestApiUrl = "http://localhost:8111/bs/guestAuth/app/rest"; | |
32 private long myBuildId; | |
33 private File mySourcesRootDirectory; | |
34 | |
35 public SrcSrvStreamProvider(final long buildId, final File sourcesRootDirectory) { | |
36 myBuildId = buildId; | |
37 mySourcesRootDirectory = sourcesRootDirectory; | |
38 } | |
39 | |
40 public void dumpStreamToFile(File targetFile, Collection<File> sourceFiles) throws IOException { | |
41 final FileWriter fileWriter = new FileWriter(targetFile.getPath(), true); | |
42 try { | |
43 fileWriter.write("SRCSRV: ini ------------------------------------------------"); | |
44 fileWriter.write(String.format("VERSION=%d", 1)); | |
45 fileWriter.write(String.format("INDEXVERSION=%d", 1)); | |
46 fileWriter.write("VERCTRL=http"); | |
47 fileWriter.write(String.format("DATETIME=%s", (new Date()).toString())); | |
48 | |
49 fileWriter.write("SRCSRV: variables ------------------------------------------"); | |
50 fileWriter.write("SRCSRVVERCTRL=http"); | |
51 fileWriter.write(String.format("REST_API_URL=%s", myRestApiUrl)); | |
52 fileWriter.write(String.format("BUILD_LOCATOR=id:%d", myBuildId)); | |
53 fileWriter.write("HTTP_EXTRACT_TARGET=%REST_API_URL%/%BUILD_LOCATOR%/sources/files/%var2%"); | |
54 fileWriter.write("SRCSRVTRG=%HTTP_EXTRACT_TARGET%"); | |
55 fileWriter.write("SRCSRVCMD="); | |
56 | |
57 final URI checkoutDirUri = mySourcesRootDirectory.toURI(); | |
58 fileWriter.write("SRCSRV: source files ------------------------------------------"); | |
59 for(File sourceFile : sourceFiles){ | |
60 final File sourceFileAbsolute = sourceFile.getAbsoluteFile(); | |
61 fileWriter.write(String.format("%s*%s", sourceFileAbsolute.getPath(), checkoutDirUri.relativize(sourceFileAbsolute.toURI()).getPath())); | |
62 } | |
63 | |
64 fileWriter.write("SRCSRV: end ------------------------------------------------"); | |
65 } | |
66 finally { | |
67 fileWriter.close(); | |
68 } | |
69 } | |
70 } |