cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [1/2] cayenne git commit: Add logger to cgen tasks to log what config is using.
Date Sat, 17 Nov 2018 13:11:27 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 8523da7df -> 0c335d5e4


Add logger to cgen tasks to log what config is using.


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/e480d713
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/e480d713
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/e480d713

Branch: refs/heads/master
Commit: e480d7134391e2549c268c6e588d2d707693cb08
Parents: b580bda
Author: Arseni Bulatski <ancarseni@gmail.com>
Authored: Thu Nov 15 13:42:13 2018 +0300
Committer: Arseni Bulatski <ancarseni@gmail.com>
Committed: Thu Nov 15 13:44:00 2018 +0300

----------------------------------------------------------------------
 .../cayenne/tools/CayenneGeneratorTask.java     |  7 ++++++-
 .../java/org/apache/cayenne/tools/CgenTask.java | 21 ++++++++------------
 .../org/apache/cayenne/tools/CgenTaskTest.java  |  2 ++
 .../cayenne/tools/CayenneGeneratorMojo.java     |  3 +++
 4 files changed, 19 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/e480d713/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
----------------------------------------------------------------------
diff --git a/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
b/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
index 8d5a151..f8b43d5 100644
--- a/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
+++ b/cayenne-ant/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
@@ -44,6 +44,8 @@ import java.io.File;
  */
 public class CayenneGeneratorTask extends CayenneTask {
 
+    private AntLogger logger;
+
     protected String includeEntitiesPattern;
     protected String excludeEntitiesPattern;
     /**
@@ -104,7 +106,7 @@ public class CayenneGeneratorTask extends CayenneTask {
 
         injector = DIBootstrap.createInjector(new CgenModule(), new ToolsModule(LoggerFactory.getLogger(CayenneGeneratorTask.class)));
 
-        AntLogger logger = new AntLogger(this);
+        logger = new AntLogger(this);
         CayenneGeneratorMapLoaderAction loadAction = new CayenneGeneratorMapLoaderAction(injector);
 
         loadAction.setMainDataMapFile(map);
@@ -160,11 +162,14 @@ public class CayenneGeneratorTask extends CayenneTask {
     private CgenConfiguration buildConfiguration(DataMap dataMap) {
         CgenConfiguration cgenConfiguration = injector.getInstance(DataChannelMetaData.class).get(dataMap,
CgenConfiguration.class);
         if(hasConfig()) {
+            logger.info("Using cgen config from pom.xml");
             return cgenConfigFromPom(dataMap);
         } else if(cgenConfiguration != null) {
+            logger.info("Using cgen config from " + cgenConfiguration.getDataMap().getName());
             useConfigFromDataMap = true;
             return cgenConfiguration;
         } else {
+            logger.info("Using default cgen config.");
             cgenConfiguration = new CgenConfiguration();
             cgenConfiguration.setDataMap(dataMap);
             return cgenConfiguration;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e480d713/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
index 818b592..234030f 100644
--- a/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
+++ b/cayenne-gradle-plugin/src/main/java/org/apache/cayenne/tools/CgenTask.java
@@ -19,12 +19,6 @@
 
 package org.apache.cayenne.tools;
 
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Set;
-
 import groovy.lang.Reference;
 import org.apache.cayenne.configuration.xml.DataChannelMetaData;
 import org.apache.cayenne.dbsync.filter.NamePatternMatcher;
@@ -41,15 +35,13 @@ import org.gradle.api.Action;
 import org.gradle.api.GradleException;
 import org.gradle.api.InvalidUserDataException;
 import org.gradle.api.plugins.JavaPlugin;
-import org.gradle.api.tasks.Input;
-import org.gradle.api.tasks.InputDirectory;
-import org.gradle.api.tasks.InputFile;
-import org.gradle.api.tasks.Optional;
-import org.gradle.api.tasks.OutputDirectory;
-import org.gradle.api.tasks.SourceSetContainer;
-import org.gradle.api.tasks.TaskAction;
+import org.gradle.api.tasks.*;
+import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
+import java.util.Set;
+
 /**
  * @since 4.0
  */
@@ -221,12 +213,15 @@ public class CgenTask extends BaseCayenneTask {
     CgenConfiguration buildConfiguration(DataMap dataMap) {
         CgenConfiguration cgenConfiguration;
         if(hasConfig()) {
+            getLogger().info("Using cgen config from pom.xml");
             return cgenConfigFromPom(dataMap);
         } else if(metaData != null && metaData.get(dataMap, CgenConfiguration.class)
!= null) {
+            getLogger().info("Using cgen config from " + dataMap.getName());
             useConfigFromDataMap = true;
             cgenConfiguration = metaData.get(dataMap, CgenConfiguration.class);
             return cgenConfiguration;
         } else {
+            getLogger().info("Using default cgen config.");
             cgenConfiguration = new CgenConfiguration();
             cgenConfiguration.setRelPath(getDestDirFile().getPath());
             cgenConfiguration.setDataMap(dataMap);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e480d713/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskTest.java
----------------------------------------------------------------------
diff --git a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskTest.java
b/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskTest.java
index e2fa3ca..00d090e 100644
--- a/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskTest.java
+++ b/cayenne-gradle-plugin/src/test/java/org/apache/cayenne/tools/CgenTaskTest.java
@@ -25,6 +25,7 @@ import org.apache.cayenne.map.DataMap;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.gradle.api.logging.Logging;
 
 import java.io.File;
 
@@ -63,6 +64,7 @@ public class CgenTaskTest {
         doCallRealMethod().when(mock).setTemplate(anyString());
         when(mock.buildConfiguration(dataMap)).thenCallRealMethod();
         when(mock.createGenerator(dataMap)).thenCallRealMethod();
+        when(mock.getLogger()).thenReturn(Logging.getLogger(CgenTaskTest.class));
 
         return mock;
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e480d713/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
b/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
index f3abbe5..74f92ce 100644
--- a/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
+++ b/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/CayenneGeneratorMojo.java
@@ -315,11 +315,14 @@ public class CayenneGeneratorMojo extends AbstractMojo {
 	private CgenConfiguration buildConfiguration(DataMap dataMap) {
 		CgenConfiguration cgenConfiguration = injector.getInstance(DataChannelMetaData.class).get(dataMap,
CgenConfiguration.class);
 		if(hasConfig()) {
+			logger.info("Using cgen config from pom.xml");
 			return cgenConfigFromPom(dataMap);
 		} else if(cgenConfiguration != null) {
+			logger.info("Using cgen config from " + cgenConfiguration.getDataMap().getName());
 			useConfigFromDataMap = true;
 			return cgenConfiguration;
 		} else {
+			logger.info("Using default cgen config.");
 			cgenConfiguration = new CgenConfiguration();
 			cgenConfiguration.setDataMap(dataMap);
 			cgenConfiguration.setRelPath(defaultDir.getPath());


Mime
View raw message