Revision 55682
Added by Claudio Atzori almost 5 years ago
DNetOpenaireExporterBeanFactory.java | ||
---|---|---|
27 | 27 |
import org.springframework.context.annotation.Bean; |
28 | 28 |
import org.springframework.context.annotation.Configuration; |
29 | 29 |
|
30 |
import java.io.FileNotFoundException; |
|
30 | 31 |
import java.io.FileReader; |
31 | 32 |
import java.io.IOException; |
32 | 33 |
|
... | ... | |
38 | 39 |
|
39 | 40 |
private static final Log log = LogFactory.getLog(DNetOpenaireExporterBeanFactory.class); |
40 | 41 |
|
42 |
private static final String[] POM_PATHS = { |
|
43 |
"META-INF/maven/eu.dnetlib/dnet-openaire-exporter/pom.xml", |
|
44 |
"eu.dnetlib/dnet-openaire-exporter/pom.xml", |
|
45 |
"/eu.dnetlib/dnet-openaire-exporter/pom.xml", |
|
46 |
"pom.xml" |
|
47 |
}; |
|
48 |
|
|
41 | 49 |
static { |
42 | 50 |
final MavenXpp3Reader reader = new MavenXpp3Reader(); |
51 |
FileReader f = null; |
|
52 |
for(final String path : POM_PATHS) { |
|
53 |
try { |
|
54 |
f = new FileReader(path); |
|
55 |
log.info("found pom file in " + path); |
|
56 |
} catch (FileNotFoundException e) { |
|
57 |
log.warn("cannot find pom file in " + path); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
if (f == null) { |
|
62 |
throw new IllegalStateException("unable to get pom information"); |
|
63 |
} |
|
43 | 64 |
try { |
44 |
final Model model = reader.read(new FileReader("pom.xml"));
|
|
65 |
final Model model = reader.read(f);
|
|
45 | 66 |
|
46 | 67 |
log.info(String.format("registering metric for %s", model.getArtifactId())); |
47 | 68 |
Metrics.gauge("micrometer_info", Lists.newArrayList( |
Also available in: Unified diff
try to access pom file on different locations