Commit 0ee03b80 by Jason Song

Merge pull request #37 from yiming187/style_update

Update checkstyle conf
parents 8d374626 61ca5c83
...@@ -7,7 +7,7 @@ before_install: ...@@ -7,7 +7,7 @@ before_install:
after_success: after_success:
- mvn clean cobertura:cobertura coveralls:report - mvn clean cobertura:cobertura coveralls:report
- mvn clean site -X - mvn clean site
- codecov - codecov
branches: branches:
......
...@@ -41,11 +41,7 @@ public class ClientEnvironment { ...@@ -41,11 +41,7 @@ public class ClientEnvironment {
if (env.get() == null) { if (env.get() == null) {
Env resultEnv = Apollo.getEnv(); Env resultEnv = Apollo.getEnv();
Properties apolloProperties = null; Properties apolloProperties = null;
try { apolloProperties = readConfigFile(DEFAULT_FILE, null);
apolloProperties = readConfigFile(DEFAULT_FILE, null);
} catch (IOException e) {
throw new IllegalArgumentException("Could not read Apollo properties");
}
if (apolloProperties != null) { if (apolloProperties != null) {
String strEnv = apolloProperties.getProperty(Constants.ENV); String strEnv = apolloProperties.getProperty(Constants.ENV);
if (!StringUtils.isBlank(strEnv)) { if (!StringUtils.isBlank(strEnv)) {
...@@ -67,26 +63,38 @@ public class ClientEnvironment { ...@@ -67,26 +63,38 @@ public class ClientEnvironment {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Properties readConfigFile(String configPath, Properties defaults) throws IOException { private Properties readConfigFile(String configPath, Properties defaults) {
InputStream in = this.getClass().getResourceAsStream(configPath); InputStream in = this.getClass().getResourceAsStream(configPath);
logger.info("Reading config from resource {}", configPath); logger.info("Reading config from resource {}", configPath);
if (in == null) {
// load outside resource under current user path
Path path = new File(System.getProperty("user.dir") + configPath).toPath();
if (Files.isReadable(path)) {
in = new FileInputStream(path.toFile());
logger.info("Reading config from file {} ", path);
}
}
Properties props = new Properties(); Properties props = new Properties();
if (defaults != null) { try {
props.putAll(defaults); if (in == null) {
} // load outside resource under current user path
Path path = new File(System.getProperty("user.dir") + configPath).toPath();
if (Files.isReadable(path)) {
in = new FileInputStream(path.toFile());
logger.info("Reading config from file {} ", path);
}
}
if (defaults != null) {
props.putAll(defaults);
}
if (in != null) { if (in != null) {
props.load(in); props.load(in);
in.close();
}
} catch (Exception e) {
logger.warn("Reading config failed: {}", e.getMessage());
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
logger.warn("Close config failed: {}", e.getMessage());
}
}
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (Enumeration<String> e = (Enumeration<String>) props.propertyNames(); e for (Enumeration<String> e = (Enumeration<String>) props.propertyNames(); e
.hasMoreElements();) { .hasMoreElements();) {
......
...@@ -2,7 +2,6 @@ package com.ctrip.apollo; ...@@ -2,7 +2,6 @@ package com.ctrip.apollo;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
/** /**
...@@ -12,7 +11,6 @@ import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; ...@@ -12,7 +11,6 @@ import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
*/ */
@SpringBootApplication @SpringBootApplication
@EnableEurekaServer @EnableEurekaServer
@EnableEurekaClient
public class ServerApplication { public class ServerApplication {
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -7,7 +7,7 @@ public class Apollo { ...@@ -7,7 +7,7 @@ public class Apollo {
private static Env m_env; private static Env m_env;
public enum Env { public enum Env {
LOCAL, DEV, FWS, FAT, UAT, LPT, PROD, TOOLS LOCAL, DEV, FWS, FAT, UAT, LPT, PRO, TOOLS
} }
public static void initialize(Env env) { public static void initialize(Env env) {
......
...@@ -29,7 +29,7 @@ public class MetaDomainConsts { ...@@ -29,7 +29,7 @@ public class MetaDomainConsts {
public static final String TOOLS = public static final String TOOLS =
"http://ws.meta.apollo.fx.tools.ctripcorp.com" + ":" + DEFAULT_PORT; "http://ws.meta.apollo.fx.tools.ctripcorp.com" + ":" + DEFAULT_PORT;
public static final String PRD = "http://ws.meta.apollo.fx.ctripcorp.com" + ":" + DEFAULT_PORT; public static final String PRO = "http://ws.meta.apollo.fx.ctripcorp.com" + ":" + DEFAULT_PORT;
private static Map<Env, String> domains = new HashMap<>(); private static Map<Env, String> domains = new HashMap<>();
...@@ -41,7 +41,7 @@ public class MetaDomainConsts { ...@@ -41,7 +41,7 @@ public class MetaDomainConsts {
domains.put(Env.UAT, UAT); domains.put(Env.UAT, UAT);
domains.put(Env.LPT, LPT); domains.put(Env.LPT, LPT);
domains.put(Env.TOOLS, TOOLS); domains.put(Env.TOOLS, TOOLS);
domains.put(Env.PROD, PRD); domains.put(Env.PRO, PRO);
} }
public static String getDomain(Env env) { public static String getDomain(Env env) {
......
...@@ -104,11 +104,11 @@ ...@@ -104,11 +104,11 @@
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version> <version>5.1.38</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>19.0</version> <version>19.0</version>
</dependency> </dependency>
<!--for test --> <!--for test -->
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
...@@ -161,25 +161,31 @@ ...@@ -161,25 +161,31 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<version>2.3</version> <version>2.3</version>
<configuration> <configuration>
<failOnMissingWebXml>false</failOnMissingWebXml> <failOnMissingWebXml>false</failOnMissingWebXml>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version> <version>2.17</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.puppycrawl.tools</groupId> <groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId> <artifactId>checkstyle</artifactId>
<version>6.16.1</version> <version>6.16.1</version>
</dependency> </dependency>
</dependencies> </dependencies>
<configuration>
<configLocation>google_checks.xml</configLocation>
<failOnViolation>false</failOnViolation>
<linkXRef>false</linkXRef>
<consoleOutput>true</consoleOutput>
</configuration>
</plugin> </plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
...@@ -203,10 +209,6 @@ ...@@ -203,10 +209,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>google_checks.xml</configLocation>
<failOnViolation>false</failOnViolation>
</configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
...@@ -240,7 +242,7 @@ ...@@ -240,7 +242,7 @@
</build> </build>
</profile> </profile>
</profiles> </profiles>
<repositories> <repositories>
<repository> <repository>
<id>spring-milestones</id> <id>spring-milestones</id>
...@@ -256,10 +258,6 @@ ...@@ -256,10 +258,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>google_checks.xml</configLocation>
<failOnViolation>false</failOnViolation>
</configuration>
</plugin> </plugin>
</plugins> </plugins>
</reporting> </reporting>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment