├── .gitignore ├── .travis.yml ├── README.md ├── circle.yml ├── pom.xml └── src ├── it ├── check-invoke-it │ ├── build.gradle │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── test │ │ │ └── TestBean.java │ └── verify.groovy └── main-it │ ├── build.gradle │ ├── pom.xml │ ├── src │ └── main │ │ └── java │ │ └── test │ │ └── TestBean.java │ └── verify.groovy ├── main └── java │ └── org │ ├── fortasoft │ └── maven │ │ └── plugin │ │ └── gradle │ │ ├── GradleArgs.java │ │ └── GradleMojo.java │ └── slf4j │ └── impl │ ├── MavenLogWrapper.java │ ├── MojoLoggerFactory.java │ ├── NewMojoLogger.java │ ├── StaticLoggerBinder.java │ ├── StaticMDCBinder.java │ └── StaticMarkerBinder.java └── test └── java └── test └── MessageFormatTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .classpath 3 | .project 4 | .settings/ 5 | 6 | # Intellij 7 | .idea/ 8 | *.iml 9 | *.iws 10 | 11 | # Mac 12 | .DS_Store 13 | 14 | # Maven 15 | log/ 16 | target/ 17 | site/ 18 | 19 | # Gradle 20 | .gradle/ 21 | 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | script: mvn integration-test 3 | jdk: 4 | - oraclejdk8 5 | - oraclejdk7 6 | - openjdk7 7 | 8 | branches: 9 | only: 10 | - master 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is fork of **LendingClub/gradle-maven-plugin** with basic maintenance. 2 | 3 | # gradle-maven-plugin 4 | 5 | This is a maven plugin that makes it easy to invoke Gradle tasks from within Maven. 6 | 7 | # Objective 8 | 9 | Gradle is an awesome general-purpose tool. If your project/organization is committed to maven, switching to gradle may not 10 | be a practical option. The plugin is conceptually similar to the maven-antrun-plugin, which allows ant to be invoked from maven. 11 | 12 | Now instead of using Ant to perform ad-hoc tasks from within Maven, you can use Groovy/Gradle instead! 13 | 14 | # Usage 15 | 16 | The gradle-maven-plugin is now in Maven Central, so there is no need to declare a custom repository. 17 | 18 | To use the plugin, simply declare the plugin and bind it to the maven lifecycle phase of your choice: 19 | 20 | ```xml 21 | 22 | org.fortasoft 23 | gradle-maven-plugin 24 | 1.0.8 25 | 26 | 27 | 28 | doSomething 29 | 30 | 31 | 32 | 33 | 34 | compile 35 | 36 | 37 | invoke 38 | 39 | 40 | 41 | 42 | ``` 43 | 44 | Now when you run maven, gradle will be invoked and execute the "doSomething" task defined in `build.gradle`. 45 | 46 | Obviously you can change the task(s) to suit your needs. 47 | 48 | In this example, the gradle invocation will happen during the maven "compile" phase, but this can be easily changed by changing 49 | the <phase> element value. 50 | 51 | ## Options 52 | These options can be given in the <configuration> element: 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 65 |
optionrequireddescriptionexample
taskyes (or tasks) gradle task to be invoked
<task>myTask</task>
tasksyes (or task) gradle tasks to be invoked
<tasks>
<task>task1</task>
<task>task2</task>
</tasks>
gradleVersionnoversion of gradle to use
<gradleVersion>1.6</gradleVersion>
gradleProjectDirectorynopath to the location of your build.gradle
<gradleProjectDirectory>
${project.basedir}/another/path
</gradleProjectDirectory>
javaHomenogive and explicit path to a JAVA_HOME
<javaHome> /my/path/to/jdk </javaHome>
argsnopass argument to gradle
<args>
<arg>-q</arg>
</args>
jvmArgsnopass JVM arg to gradle
<jvmArgs>
<jvmArg>-XX:MaxPermSize=128m</jvmArg>
64 | <jvmArg>-Xmx256m</jvmArg>
</jvmArgs>
66 | 67 | # Plugin Testing 68 | 69 | Here is some information on maven plugin testing. This project is currently using the maven-invoker-plugin for testing. 70 | 71 | * http://maven.apache.org/plugin-developers/plugin-testing.html 72 | * http://maven.apache.org/plugins/maven-invoker-plugin/usage.html 73 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | java: 3 | version: oraclejdk7 4 | environment: 5 | TERM: dumb 6 | 7 | 8 | general: 9 | artifacts: 10 | - "target/*.jar" 11 | 12 | 13 | test: 14 | override: 15 | - mvn -B clean install 16 | post: 17 | - mkdir -p $CIRCLE_TEST_REPORTS/junit/ 18 | - find . -type f -regex ".*/target/surefire-reports/.*.xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \; 19 | - find . -type f -regex ".*/target/invoker-reports/.*.xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \; -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | codes.rafael.gradlemavenplugin 5 | gradle-maven-plugin 6 | maven-plugin 7 | 1.0.12-SNAPSHOT 8 | gradle-maven-plugin Maven Mojo 9 | https://github.com/LendingClub/gradle-maven-plugin 10 | 11 | org.sonatype.oss 12 | oss-parent 13 | 7 14 | 15 | 16 | 17 | The Apache Software License, Version 2.0 18 | http://www.apache.org/licenses/LICENSE-2.0.txt 19 | repo 20 | 21 | 22 | 23 | scm:git:git@github.com:raphw/gradle-maven-plugin.git 24 | scm:git:git@github.com:raphw/gradle-maven-plugin.git 25 | git@github.com:raphw/gradle-maven-plugin.git 26 | 27 | 28 | 29 | rob 30 | Rob Schoening 31 | robschoening@gmail.com 32 | 33 | 34 | raphw 35 | Rafael Winterhalter 36 | rafael.wth@gmail.com 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.apache.maven.plugins 45 | maven-plugin-plugin 46 | 3.6.0 47 | 48 | true 49 | 50 | 51 | 52 | mojo-descriptor 53 | 54 | descriptor 55 | 56 | process-classes 57 | 58 | 59 | 60 | 61 | org.apache.maven.plugins 62 | maven-source-plugin 63 | 3.0.1 64 | 65 | 66 | attach-sources 67 | 68 | jar 69 | 70 | 71 | 72 | 73 | 74 | maven-compiler-plugin 75 | 3.8.0 76 | 77 | 1.8 78 | 1.8 79 | 80 | 81 | 82 | org.apache.maven.plugins 83 | maven-invoker-plugin 84 | 3.2.0 85 | 86 | false 87 | ${project.build.directory}/it 88 | src/it 89 | 90 | 91 | **/pom.xml 92 | 93 | verify 94 | 98 | true 99 | 100 | 101 | 102 | integration-test 103 | 104 | install 105 | run 106 | 107 | 108 | 109 | 110 | 111 | maven-shade-plugin 112 | 2.3 113 | 114 | 115 | package 116 | 117 | shade 118 | 119 | 120 | org.slf4j 121 | false 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | org.apache.maven.plugin-tools 132 | maven-plugin-annotations 133 | 3.6.0 134 | provided 135 | 136 | 137 | 138 | org.apache.maven 139 | maven-plugin-api 140 | 3.6.0 141 | 142 | 143 | org.apache.maven 144 | maven-core 145 | 3.6.0 146 | 147 | 148 | org.slf4j 149 | slf4j-api 150 | 1.7.5 151 | compile 152 | 153 | 154 | org.gradle 155 | gradle-tooling-api 156 | 5.2.1 157 | 158 | 159 | junit 160 | junit 161 | 4.12 162 | test 163 | 164 | 165 | org.codehaus.groovy 166 | groovy-all 167 | 2.5.6 168 | pom 169 | 170 | 171 | 172 | 173 | 174 | gradle 175 | https://repo.gradle.org/gradle/libs-releases-local/ 176 | 177 | 178 | 179 | 180 | 181 | bintray 182 | https://api.bintray.com/maven/raphw/maven/gradle-maven-plugin 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /src/it/check-invoke-it/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven' 2 | apply plugin: 'java' 3 | 4 | 5 | 6 | task doIt << { 7 | throw new GradleException("forced failure") 8 | } -------------------------------------------------------------------------------- /src/it/check-invoke-it/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | org.fortasoft.test 5 | check-invoke-it 6 | jar 7 | 1.0.8 8 | gradle-maven-plugin Maven Mojo 9 | http://maven.apache.org 10 | 11 | 12 | 13 | maven-compiler-plugin 14 | 3.8.0 15 | 16 | 1.8 17 | 1.8 18 | 19 | 20 | 21 | codes.rafael.gradlemavenplugin 22 | gradle-maven-plugin 23 | 1.0.12-SNAPSHOT 24 | 25 | 26 | doIt 27 | 28 | 29 | 30 | 38 | 39 | 49 | 50 | 51 | 52 | test 53 | 54 | invoke 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/it/check-invoke-it/src/main/java/test/TestBean.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | public class TestBean { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/it/check-invoke-it/verify.groovy: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/it/main-it/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven' 2 | apply plugin: 'java' 3 | 4 | 5 | clean{ 6 | doLast { 7 | File f = new File("build/classes/main/test/TestBean.class"); 8 | if (f.exists()) { 9 | throw new GradleException("compiled TestBean should be gone"); 10 | } 11 | } 12 | } 13 | task writeFile { 14 | doLast { 15 | File f = new File(rootDir, "build/output.txt"); 16 | f.setText("hello"); 17 | } 18 | } -------------------------------------------------------------------------------- /src/it/main-it/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | codes.rafael.gradlemavenplugin 5 | gradle-maven-plugin-test 6 | jar 7 | 1.0.12-SNAPSHOT 8 | gradle-maven-plugin Maven Mojo 9 | http://maven.apache.org 10 | 11 | 12 | 13 | maven-compiler-plugin 14 | 3.8.0 15 | 16 | 1.8 17 | 1.8 18 | 19 | 20 | 21 | codes.rafael.gradlemavenplugin 22 | gradle-maven-plugin 23 | 1.0.12-SNAPSHOT 24 | 25 | 26 | clean 27 | compileJava 28 | writeFile 29 | 30 | 40 | 41 | 42 | 43 | compile 44 | 45 | invoke 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/it/main-it/src/main/java/test/TestBean.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | public class TestBean { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/it/main-it/verify.groovy: -------------------------------------------------------------------------------- 1 | 2 | // This file will check that test.txt was created by gradle 3 | 4 | File f = new File(basedir,"./build/output.txt"); 5 | 6 | if (!f.exists()) { 7 | throw new FileNotFoundException("File not found: "+f.getAbsolutePath()) 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/fortasoft/maven/plugin/gradle/GradleArgs.java: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Rob Schoening - http://www.github.com/if6was9 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package org.fortasoft.maven.plugin.gradle; 16 | 17 | import java.util.Collection; 18 | 19 | public enum GradleArgs { 20 | 21 | OFFLINE("o","offline"); 22 | 23 | private String shortValue; 24 | private String longValue; 25 | 26 | GradleArgs(String shortValue) { 27 | this.shortValue = String.format("-%s", shortValue); 28 | } 29 | 30 | GradleArgs(String shortValue, String longValue) { 31 | this(shortValue); 32 | this.longValue = String.format("--%s", longValue); 33 | } 34 | 35 | public String getShortValue() { 36 | return shortValue; 37 | } 38 | 39 | public String getLongValue() { 40 | return longValue; 41 | } 42 | 43 | public boolean exists(Collection args) { 44 | boolean result = false; 45 | 46 | if (args != null) { 47 | // first check short value 48 | result = args.contains(shortValue); 49 | 50 | if (!result && longValue != null) { 51 | result = args.contains(shortValue); 52 | } 53 | } 54 | 55 | return result; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/fortasoft/maven/plugin/gradle/GradleMojo.java: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Rob Schoening - http://www.github.com/if6was9 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package org.fortasoft.maven.plugin.gradle; 16 | 17 | import org.apache.maven.plugin.AbstractMojo; 18 | import org.apache.maven.plugin.MojoExecutionException; 19 | import org.apache.maven.plugin.MojoFailureException; 20 | import org.gradle.tooling.BuildLauncher; 21 | import org.gradle.tooling.GradleConnectionException; 22 | import org.gradle.tooling.GradleConnector; 23 | import org.gradle.tooling.ProgressEvent; 24 | import org.gradle.tooling.ProgressListener; 25 | import org.gradle.tooling.ProjectConnection; 26 | import org.gradle.tooling.ResultHandler; 27 | import org.slf4j.impl.MavenLogWrapper; 28 | import org.slf4j.impl.NewMojoLogger; 29 | 30 | import groovy.lang.Binding; 31 | import groovy.lang.GroovyShell; 32 | 33 | import java.io.File; 34 | import java.io.FileWriter; 35 | import java.io.IOException; 36 | import java.net.URI; 37 | import java.net.URISyntaxException; 38 | import java.util.Arrays; 39 | import java.util.ArrayList; 40 | import java.util.List; 41 | import java.util.Map; 42 | import java.util.Properties; 43 | 44 | import org.apache.maven.plugins.annotations.Parameter; 45 | import org.apache.maven.plugins.annotations.Mojo; 46 | 47 | import org.apache.maven.execution.MavenSession; 48 | 49 | /** 50 | * Goal which invokes gradle! 51 | * 52 | */ 53 | @Mojo(name="invoke") 54 | public class GradleMojo extends AbstractMojo { 55 | 56 | /** 57 | Any maven property with this prefix automatically gets added as a 58 | gradle property 59 | */ 60 | public static final String PROP_PREFIX = "gradle.prop."; 61 | 62 | /** 63 | Any maven property with this prefix automatically gets added as a 64 | system property 65 | */ 66 | public static final String SYS_PREFIX = "gradle.sys."; 67 | 68 | @Parameter(defaultValue="5.2.1", required=true) 69 | private String gradleVersion; 70 | 71 | 72 | @Parameter(defaultValue="${tasks}") 73 | private String[] tasks; 74 | 75 | 76 | @Parameter(defaultValue="${task}") 77 | private String task; 78 | 79 | 80 | @Parameter(defaultValue="${project.basedir}") 81 | private File gradleProjectDirectory; 82 | 83 | @Parameter 84 | private String checkInvokeScript; 85 | 86 | @Parameter 87 | private String[] args; 88 | 89 | @Parameter 90 | private String[] jvmArgs; 91 | 92 | @Parameter 93 | private File javaHome; 94 | 95 | @Parameter(defaultValue="${project.basedir}", 96 | required=true) 97 | private File mavenBaseDir; 98 | 99 | 100 | // http://www.gradle.org/docs/current/javadoc/org/gradle/tooling/GradleConnector.html#useDistribution(java.net.URI) 101 | @Parameter 102 | private String gradleDistribution; 103 | 104 | // http://www.gradle.org/docs/current/javadoc/org/gradle/tooling/GradleConnector.html#useDistribution(java.net.URI) 105 | @Parameter 106 | private String gradleDistributionFile; 107 | 108 | // http://www.gradle.org/docs/current/javadoc/org/gradle/tooling/GradleConnector.html#useGradleUserHomeDir(java.io.File) 109 | @Parameter 110 | private File gradleUserHomeDir; 111 | 112 | // http://www.gradle.org/docs/current/javadoc/org/gradle/tooling/GradleConnector.html#useInstallation(java.io.File) 113 | @Parameter 114 | private File gradleInstallationDir; 115 | 116 | @Parameter( defaultValue = "${session}", readonly = true ) 117 | private MavenSession session; 118 | 119 | File getGradleProjectDirectory() { 120 | return gradleProjectDirectory; 121 | } 122 | 123 | 124 | 125 | String[] getTasks() throws MojoFailureException { 126 | 127 | String[] theTasks; 128 | 129 | if (task != null) { 130 | if (tasks != null) { 131 | throw new MojoFailureException( 132 | " and are mutually exclusive"); 133 | } 134 | theTasks = new String[] { task }; 135 | } else if (tasks != null) { 136 | if (tasks.length > 0) { 137 | theTasks = tasks; 138 | } else { 139 | throw new MojoFailureException( 140 | "No elements specified within "); 141 | } 142 | } else { 143 | throw new MojoFailureException( 144 | " or elements are mandatory"); 145 | } 146 | 147 | return theTasks; 148 | 149 | } 150 | 151 | protected GradleConnectionException gradleConnectionException; 152 | 153 | volatile boolean invocationComplete = false; 154 | 155 | class MyProgressListener implements ProgressListener { 156 | @Override 157 | public void statusChanged(ProgressEvent arg0) { 158 | getLog().info(arg0.getDescription()); 159 | 160 | } 161 | } 162 | 163 | class MyResultHandler implements ResultHandler { 164 | @Override 165 | public void onComplete(Void arg0) { 166 | 167 | invocationComplete = true; 168 | 169 | getLog().info("gradle execution complete"); 170 | 171 | } 172 | 173 | @Override 174 | public void onFailure(GradleConnectionException arg0) { 175 | synchronized (this) { 176 | invocationComplete = true; 177 | } 178 | gradleConnectionException = arg0; 179 | } 180 | } 181 | 182 | protected boolean shouldExecute() throws MojoFailureException { 183 | boolean shouldExecute = true; 184 | if (checkInvokeScript != null && checkInvokeScript.trim().length() > 0) { 185 | Binding b = new Binding(); 186 | 187 | b.setVariable("mavenBaseDir", mavenBaseDir); 188 | GroovyShell gs = new GroovyShell(b); 189 | 190 | Object rval = gs.evaluate(checkInvokeScript); 191 | 192 | if (rval != null && rval instanceof Boolean) { 193 | shouldExecute = (Boolean) rval; 194 | } else { 195 | throw new MojoFailureException( 196 | "checkScript must return boolean"); 197 | } 198 | } 199 | 200 | return shouldExecute; 201 | } 202 | 203 | public void execute() throws MojoExecutionException, MojoFailureException { 204 | 205 | ProjectConnection connection = null; 206 | try { 207 | NewMojoLogger.attachMojo(this); 208 | 209 | if (!shouldExecute()) { 210 | return; 211 | } 212 | 213 | GradleConnector c = GradleConnector.newConnector(); 214 | getLog().info("jvmArgs: " + Arrays.toString(args)); 215 | getLog().info( 216 | "gradleProjectDirectory: " 217 | + getGradleProjectDirectory().getAbsolutePath()); 218 | c = c.useGradleVersion(gradleVersion).forProjectDirectory( 219 | getGradleProjectDirectory()); 220 | 221 | if (gradleInstallationDir != null) { 222 | getLog().info( 223 | "gradleInstallation: " 224 | + gradleInstallationDir.getAbsolutePath()); 225 | c = c.useInstallation(gradleInstallationDir); 226 | } 227 | 228 | if (gradleUserHomeDir != null) { 229 | getLog().info( 230 | "gradleUserHome: " 231 | + gradleUserHomeDir.getAbsolutePath()); 232 | c = c.useGradleUserHomeDir(gradleUserHomeDir); 233 | } 234 | if (gradleDistribution != null) { 235 | getLog().info("gradleDistributionUri: " + gradleDistribution); 236 | c = c.useDistribution(new URI(gradleDistribution)); 237 | } else if (gradleDistributionFile != null) { 238 | getLog().info("gradleDistributionFile: " + gradleDistributionFile); 239 | c = c.useDistribution(new File(gradleDistributionFile).toURI()); 240 | } 241 | 242 | connection = c.connect(); 243 | 244 | BuildLauncher launcher = connection.newBuild(); 245 | launcher.forTasks(getTasks()); 246 | 247 | // Make sure to setStandardOut & Error otherwise 248 | // basic gradle build output will be lost 249 | // making troubleshooting hard 250 | launcher.setStandardOutput(System.out); 251 | launcher.setStandardError(System.err); 252 | 253 | if (jvmArgs != null && jvmArgs.length > 0) { 254 | launcher.setJvmArguments(jvmArgs); 255 | } 256 | 257 | String[] finalArgs = buildFinalArgs(args); 258 | 259 | if (finalArgs.length > 0) { 260 | launcher.withArguments(finalArgs); 261 | } 262 | if (javaHome != null) { 263 | launcher.setJavaHome(javaHome); 264 | } 265 | 266 | launcher.addProgressListener(new MyProgressListener()); 267 | 268 | // launcher will not block 269 | launcher.run(new MyResultHandler()); 270 | 271 | waitForGradleToComplete(); 272 | 273 | if (gradleConnectionException != null) { 274 | throw new MojoFailureException(gradleConnectionException, 275 | gradleConnectionException.toString(), 276 | gradleConnectionException.toString()); 277 | } 278 | } 279 | catch (URISyntaxException e) { 280 | throw new MojoFailureException("gradleDistribution is not in URI syntax"); 281 | } finally { 282 | if (connection != null) { 283 | connection.close(); 284 | } 285 | NewMojoLogger.detachMojo(); 286 | } 287 | } 288 | 289 | /* 290 | * Right now this is only conditionally adding 291 | * gradle offline option to command line, but 292 | * there is additional functionality we can do 293 | * in the future. 294 | */ 295 | private String[] buildFinalArgs(String[] args) { 296 | 297 | List argList = new ArrayList(); 298 | 299 | if (args != null) { 300 | argList.addAll(Arrays.asList(args)); 301 | } 302 | 303 | boolean offline = session.getSettings().isOffline(); 304 | 305 | // If we're offline in maven, let's be offline 306 | // in gradle as well. 307 | if (offline && !GradleArgs.OFFLINE.exists(argList)) { 308 | argList.add(GradleArgs.OFFLINE.getLongValue()); 309 | } 310 | 311 | // convert any maven properties prefaced with "gradle.prop" to 312 | // an argument. 313 | for (Map.Entry entry: System.getProperties().entrySet()) { 314 | String key = (String) entry.getKey(); 315 | 316 | if (key.startsWith(PROP_PREFIX)) { 317 | String arg = "-P" + key.substring(PROP_PREFIX.length()) + "=" + entry.getValue().toString(); 318 | getLog().info("additional argument: " + arg); 319 | argList.add(arg); 320 | } else if (key.startsWith(SYS_PREFIX)) { 321 | String arg = "-D" + key.substring(SYS_PREFIX.length()) + "=" + entry.getValue().toString(); 322 | getLog().info("additional argument: " + arg); 323 | argList.add(arg); 324 | } 325 | } 326 | 327 | // convert back to array 328 | return argList.toArray(new String[argList.size()]); 329 | } 330 | 331 | synchronized void waitForGradleToComplete() { 332 | while (!invocationComplete) { 333 | try { 334 | this.wait(50L); 335 | } catch (InterruptedException e) { 336 | } 337 | getLog().debug("waiting...."); 338 | } 339 | } 340 | } 341 | -------------------------------------------------------------------------------- /src/main/java/org/slf4j/impl/MavenLogWrapper.java: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Rob Schoening - http://www.github.com/if6was9 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package org.slf4j.impl; 16 | 17 | import org.apache.maven.plugin.logging.Log; 18 | 19 | public class MavenLogWrapper implements Log { 20 | 21 | Log myLog; 22 | 23 | MavenLogWrapper(Log log) { 24 | super(); 25 | myLog = log; 26 | } 27 | public void fallback(CharSequence arg0) { 28 | System.err.println("SLF4J: "+arg0); 29 | } 30 | public void fallback(CharSequence arg0, Throwable t) { 31 | System.err.println("SLF4J: "+arg0 +" "+t.toString()); 32 | } 33 | public void debug(CharSequence arg0) { 34 | if (myLog!=null) { 35 | myLog.debug(arg0); 36 | } 37 | else { 38 | fallback(arg0); 39 | } 40 | } 41 | 42 | @Override 43 | public void debug(Throwable arg0) { 44 | if (myLog!=null) { 45 | myLog.debug(arg0); 46 | } 47 | else { 48 | fallback("",arg0); 49 | } 50 | } 51 | 52 | @Override 53 | public void debug(CharSequence arg0, Throwable arg1) { 54 | if (myLog!=null) { 55 | myLog.debug(arg0,arg1); 56 | } 57 | else { 58 | fallback(arg0,arg1); 59 | } 60 | } 61 | 62 | public void error(CharSequence arg0) { 63 | if (myLog!=null) { 64 | myLog.error(arg0); 65 | } 66 | else { 67 | fallback(arg0); 68 | } 69 | } 70 | 71 | @Override 72 | public void error(Throwable arg0) { 73 | if (myLog!=null) { 74 | myLog.error(arg0); 75 | } 76 | else { 77 | fallback("",arg0); 78 | } 79 | } 80 | 81 | @Override 82 | public void error(CharSequence arg0, Throwable arg1) { 83 | if (myLog!=null) { 84 | myLog.error(arg0,arg1); 85 | } 86 | else { 87 | fallback(arg0,arg1); 88 | } 89 | } 90 | 91 | 92 | 93 | public void warn(CharSequence arg0) { 94 | if (myLog!=null) { 95 | myLog.warn(arg0); 96 | } 97 | else { 98 | fallback(arg0); 99 | } 100 | } 101 | 102 | @Override 103 | public void warn(Throwable arg0) { 104 | if (myLog!=null) { 105 | myLog.warn(arg0); 106 | } 107 | else { 108 | fallback("",arg0); 109 | } 110 | } 111 | 112 | @Override 113 | public void warn(CharSequence arg0, Throwable arg1) { 114 | if (myLog!=null) { 115 | myLog.warn(arg0,arg1); 116 | } 117 | else { 118 | fallback(arg0,arg1); 119 | } 120 | } 121 | 122 | 123 | public void info(CharSequence arg0) { 124 | if (myLog!=null) { 125 | myLog.info(arg0); 126 | } 127 | else { 128 | fallback(arg0); 129 | } 130 | } 131 | 132 | @Override 133 | public void info(Throwable arg0) { 134 | if (myLog!=null) { 135 | myLog.info(arg0); 136 | } 137 | else { 138 | fallback("",arg0); 139 | } 140 | } 141 | 142 | @Override 143 | public void info(CharSequence arg0, Throwable arg1) { 144 | if (myLog!=null) { 145 | myLog.info(arg0,arg1); 146 | } 147 | else { 148 | fallback(arg0,arg1); 149 | } 150 | } 151 | @Override 152 | public boolean isDebugEnabled() { 153 | if (myLog!=null) { 154 | return myLog.isDebugEnabled(); 155 | } 156 | else { 157 | return true; 158 | } 159 | } 160 | @Override 161 | public boolean isErrorEnabled() { 162 | if (myLog!=null) { 163 | return myLog.isErrorEnabled(); 164 | } 165 | else { 166 | return true; 167 | } 168 | } 169 | @Override 170 | public boolean isInfoEnabled() { 171 | if (myLog!=null) { 172 | return myLog.isInfoEnabled(); 173 | } 174 | else { 175 | return true; 176 | } 177 | } 178 | @Override 179 | public boolean isWarnEnabled() { 180 | if (myLog!=null) { 181 | return myLog.isWarnEnabled(); 182 | } 183 | else { 184 | return true; 185 | } 186 | } 187 | 188 | 189 | } 190 | -------------------------------------------------------------------------------- /src/main/java/org/slf4j/impl/MojoLoggerFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2004-2011 QOS.ch 3 | * All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining 6 | * a copy of this software and associated documentation files (the 7 | * "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, 9 | * distribute, sublicense, and/or sell copies of the Software, and to 10 | * permit persons to whom the Software is furnished to do so, subject to 11 | * the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | * 24 | */ 25 | package org.slf4j.impl; 26 | 27 | import java.util.HashMap; 28 | import java.util.Map; 29 | 30 | import org.slf4j.Logger; 31 | import org.slf4j.ILoggerFactory; 32 | 33 | /** 34 | * An implementation of {@link ILoggerFactory} which always returns a MojoLogger instances. 35 | * 36 | * @author Ceki Gülcü 37 | */ 38 | public class MojoLoggerFactory implements ILoggerFactory { 39 | 40 | final static MojoLoggerFactory INSTANCE = new MojoLoggerFactory(); 41 | 42 | Map loggerMap; 43 | 44 | public MojoLoggerFactory() { 45 | 46 | loggerMap = new HashMap(); 47 | } 48 | 49 | /** 50 | * Return an appropriate logger instance by name. 51 | */ 52 | public Logger getLogger(String name) { 53 | return new NewMojoLogger(); 54 | } 55 | } -------------------------------------------------------------------------------- /src/main/java/org/slf4j/impl/NewMojoLogger.java: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Rob Schoening - http://www.github.com/if6was9 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package org.slf4j.impl; 16 | 17 | import java.util.LinkedList; 18 | import java.util.concurrent.CopyOnWriteArrayList; 19 | 20 | import org.apache.maven.plugin.AbstractMojo; 21 | import org.apache.maven.plugin.logging.Log; 22 | import org.slf4j.helpers.FormattingTuple; 23 | import org.slf4j.helpers.MessageFormatter; 24 | 25 | public class NewMojoLogger extends org.slf4j.helpers.MarkerIgnoringBase { 26 | 27 | static LinkedList mojoStack = new LinkedList(); 28 | 29 | public synchronized static void detachMojo() { 30 | mojoStack.pop(); 31 | } 32 | 33 | public synchronized static void attachMojo(AbstractMojo mojo) { 34 | mojoStack.addFirst(mojo); 35 | 36 | } 37 | 38 | Log getLog() { 39 | if (mojoStack.peek() != null) { 40 | return new MavenLogWrapper(mojoStack.peek().getLog()); 41 | } else { 42 | return new MavenLogWrapper(null); 43 | } 44 | } 45 | 46 | 47 | ////// 48 | @Override 49 | public void debug(String arg0) { 50 | 51 | FormattingTuple tp = MessageFormatter.format(arg0, null); 52 | getLog().debug(tp.getMessage()); 53 | 54 | } 55 | 56 | @Override 57 | public void debug(String arg0, Object arg1) { 58 | FormattingTuple tp = MessageFormatter.format(arg0, arg1); 59 | getLog().debug(tp.getMessage()); 60 | } 61 | 62 | @Override 63 | public void debug(String arg0, Object[] arg1) { 64 | FormattingTuple tp = MessageFormatter.arrayFormat(arg0, arg1); 65 | getLog().debug(tp.getMessage()); 66 | } 67 | 68 | @Override 69 | public void debug(String arg0, Throwable arg1) { 70 | FormattingTuple tp = MessageFormatter.format(arg0, null); 71 | getLog().debug(tp.getMessage(),arg1); 72 | } 73 | 74 | @Override 75 | public void debug(String arg0, Object arg1, Object arg2) { 76 | FormattingTuple tp = MessageFormatter.arrayFormat(arg0, new Object[] {arg1,arg2}); 77 | getLog().debug(tp.getMessage()); 78 | } 79 | 80 | // ////////// ERROR 81 | ////// 82 | @Override 83 | public void error(String arg0) { 84 | 85 | FormattingTuple tp = MessageFormatter.format(arg0, null); 86 | getLog().error(tp.getMessage()); 87 | 88 | } 89 | 90 | @Override 91 | public void error(String arg0, Object arg1) { 92 | FormattingTuple tp = MessageFormatter.format(arg0, arg1); 93 | getLog().error(tp.getMessage()); 94 | } 95 | 96 | @Override 97 | public void error(String arg0, Object[] arg1) { 98 | FormattingTuple tp = MessageFormatter.arrayFormat(arg0, arg1); 99 | getLog().error(tp.getMessage()); 100 | } 101 | 102 | @Override 103 | public void error(String arg0, Throwable arg1) { 104 | FormattingTuple tp = MessageFormatter.format(arg0, null); 105 | getLog().error(tp.getMessage(),arg1); 106 | } 107 | 108 | @Override 109 | public void error(String arg0, Object arg1, Object arg2) { 110 | FormattingTuple tp = MessageFormatter.arrayFormat(arg0, new Object[] {arg1,arg2}); 111 | getLog().error(tp.getMessage()); 112 | } 113 | 114 | 115 | 116 | 117 | ////// 118 | @Override 119 | public void info(String arg0) { 120 | 121 | FormattingTuple tp = MessageFormatter.format(arg0, null); 122 | getLog().info(tp.getMessage()); 123 | 124 | } 125 | 126 | @Override 127 | public void info(String arg0, Object arg1) { 128 | FormattingTuple tp = MessageFormatter.format(arg0, arg1); 129 | getLog().info(tp.getMessage()); 130 | } 131 | 132 | @Override 133 | public void info(String arg0, Object[] arg1) { 134 | FormattingTuple tp = MessageFormatter.arrayFormat(arg0, arg1); 135 | getLog().info(tp.getMessage()); 136 | } 137 | 138 | @Override 139 | public void info(String arg0, Throwable arg1) { 140 | FormattingTuple tp = MessageFormatter.format(arg0, null); 141 | getLog().info(tp.getMessage(),arg1); 142 | } 143 | 144 | @Override 145 | public void info(String arg0, Object arg1, Object arg2) { 146 | FormattingTuple tp = MessageFormatter.arrayFormat(arg0, new Object[] {arg1,arg2}); 147 | getLog().info(tp.getMessage()); 148 | } 149 | 150 | 151 | 152 | @Override 153 | public boolean isDebugEnabled() { 154 | 155 | return getLog().isDebugEnabled(); 156 | } 157 | 158 | @Override 159 | public boolean isErrorEnabled() { 160 | 161 | return getLog().isErrorEnabled(); 162 | } 163 | 164 | @Override 165 | public boolean isInfoEnabled() { 166 | 167 | return getLog().isInfoEnabled(); 168 | } 169 | 170 | @Override 171 | public boolean isTraceEnabled() { 172 | 173 | return getLog().isDebugEnabled(); 174 | } 175 | 176 | @Override 177 | public boolean isWarnEnabled() { 178 | 179 | return getLog().isWarnEnabled(); 180 | } 181 | 182 | @Override 183 | public void trace(String arg0) { 184 | 185 | FormattingTuple tp = MessageFormatter.format(arg0, null); 186 | getLog().debug(tp.getMessage()); 187 | 188 | } 189 | 190 | @Override 191 | public void trace(String arg0, Object arg1) { 192 | FormattingTuple tp = MessageFormatter.format(arg0, arg1); 193 | getLog().debug(tp.getMessage()); 194 | } 195 | 196 | @Override 197 | public void trace(String arg0, Object[] arg1) { 198 | FormattingTuple tp = MessageFormatter.arrayFormat(arg0, arg1); 199 | getLog().debug(tp.getMessage()); 200 | } 201 | 202 | @Override 203 | public void trace(String arg0, Throwable arg1) { 204 | FormattingTuple tp = MessageFormatter.format(arg0, null); 205 | getLog().debug(tp.getMessage(),arg1); 206 | } 207 | 208 | @Override 209 | public void trace(String arg0, Object arg1, Object arg2) { 210 | FormattingTuple tp = MessageFormatter.arrayFormat(arg0, new Object[] {arg1,arg2}); 211 | getLog().debug(tp.getMessage()); 212 | } 213 | 214 | ////// 215 | @Override 216 | public void warn(String arg0) { 217 | 218 | FormattingTuple tp = MessageFormatter.format(arg0, null); 219 | getLog().warn(tp.getMessage()); 220 | 221 | } 222 | 223 | @Override 224 | public void warn(String arg0, Object arg1) { 225 | FormattingTuple tp = MessageFormatter.format(arg0, arg1); 226 | getLog().warn(tp.getMessage()); 227 | } 228 | 229 | @Override 230 | public void warn(String arg0, Object[] arg1) { 231 | FormattingTuple tp = MessageFormatter.arrayFormat(arg0, arg1); 232 | getLog().warn(tp.getMessage()); 233 | } 234 | 235 | @Override 236 | public void warn(String arg0, Throwable arg1) { 237 | FormattingTuple tp = MessageFormatter.format(arg0, null); 238 | getLog().warn(tp.getMessage(),arg1); 239 | } 240 | 241 | @Override 242 | public void warn(String arg0, Object arg1, Object arg2) { 243 | FormattingTuple tp = MessageFormatter.arrayFormat(arg0, new Object[] {arg1,arg2}); 244 | getLog().warn(tp.getMessage()); 245 | } 246 | 247 | 248 | } 249 | -------------------------------------------------------------------------------- /src/main/java/org/slf4j/impl/StaticLoggerBinder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2004-2011 QOS.ch 3 | * All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining 6 | * a copy of this software and associated documentation files (the 7 | * "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, 9 | * distribute, sublicense, and/or sell copies of the Software, and to 10 | * permit persons to whom the Software is furnished to do so, subject to 11 | * the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | * 24 | */ 25 | package org.slf4j.impl; 26 | 27 | import org.slf4j.ILoggerFactory; 28 | import org.slf4j.LoggerFactory; 29 | import org.slf4j.spi.LoggerFactoryBinder; 30 | 31 | /** 32 | * The binding of {@link LoggerFactory} class with an actual instance of 33 | * {@link ILoggerFactory} is performed using information returned by this class. 34 | * 35 | * 36 | * @author Ceki Gülcü 37 | */ 38 | public class StaticLoggerBinder implements LoggerFactoryBinder { 39 | 40 | /** 41 | * The unique instance of this class. 42 | * 43 | */ 44 | private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); 45 | 46 | /** 47 | * Return the singleton of this class. 48 | * 49 | * @return the StaticLoggerBinder singleton 50 | */ 51 | public static final StaticLoggerBinder getSingleton() { 52 | return SINGLETON; 53 | } 54 | 55 | 56 | /** 57 | * Declare the version of the SLF4J API this implementation is compiled 58 | * against. The value of this field is usually modified with each release. 59 | */ 60 | // to avoid constant folding by the compiler, this field must *not* be final 61 | public static String REQUESTED_API_VERSION = "1.6.99"; // !final 62 | 63 | private static final String loggerFactoryClassStr = MojoLoggerFactory.class.getName(); 64 | 65 | /** 66 | * The ILoggerFactory instance returned by the {@link #getLoggerFactory} 67 | * method should always be the same object 68 | */ 69 | private final ILoggerFactory loggerFactory; 70 | 71 | private StaticLoggerBinder() { 72 | loggerFactory = new MojoLoggerFactory(); 73 | } 74 | 75 | public ILoggerFactory getLoggerFactory() { 76 | return loggerFactory; 77 | } 78 | 79 | public String getLoggerFactoryClassStr() { 80 | return loggerFactoryClassStr; 81 | } 82 | } -------------------------------------------------------------------------------- /src/main/java/org/slf4j/impl/StaticMDCBinder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2004-2011 QOS.ch 3 | * All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining 6 | * a copy of this software and associated documentation files (the 7 | * "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, 9 | * distribute, sublicense, and/or sell copies of the Software, and to 10 | * permit persons to whom the Software is furnished to do so, subject to 11 | * the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | * 24 | */ 25 | package org.slf4j.impl; 26 | 27 | import org.slf4j.helpers.NOPMDCAdapter; 28 | import org.slf4j.spi.MDCAdapter; 29 | 30 | 31 | /** 32 | * This implementation is bound to {@link NOPMDCAdapter}. 33 | * 34 | * @author Ceki Gülcü 35 | */ 36 | public class StaticMDCBinder { 37 | 38 | 39 | /** 40 | * The unique instance of this class. 41 | */ 42 | public static final StaticMDCBinder SINGLETON = new StaticMDCBinder(); 43 | 44 | private StaticMDCBinder() { 45 | } 46 | 47 | /** 48 | * @return Currently this method always returns an instance of {@link StaticMDCBinder}. 49 | */ 50 | public MDCAdapter getMDCA() { 51 | return new NOPMDCAdapter(); 52 | } 53 | 54 | public String getMDCAdapterClassStr() { 55 | return NOPMDCAdapter.class.getName(); 56 | } 57 | } -------------------------------------------------------------------------------- /src/main/java/org/slf4j/impl/StaticMarkerBinder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2004-2011 QOS.ch 3 | * All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining 6 | * a copy of this software and associated documentation files (the 7 | * "Software"), to deal in the Software without restriction, including 8 | * without limitation the rights to use, copy, modify, merge, publish, 9 | * distribute, sublicense, and/or sell copies of the Software, and to 10 | * permit persons to whom the Software is furnished to do so, subject to 11 | * the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | * 24 | */ 25 | 26 | package org.slf4j.impl; 27 | 28 | import org.slf4j.IMarkerFactory; 29 | import org.slf4j.MarkerFactory; 30 | import org.slf4j.helpers.BasicMarkerFactory; 31 | import org.slf4j.spi.MarkerFactoryBinder; 32 | 33 | /** 34 | * 35 | * The binding of {@link MarkerFactory} class with an actual instance of 36 | * {@link IMarkerFactory} is performed using information returned by this class. 37 | * 38 | * @author Ceki Gülcü 39 | */ 40 | public class StaticMarkerBinder implements MarkerFactoryBinder { 41 | 42 | /** 43 | * The unique instance of this class. 44 | */ 45 | public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder(); 46 | 47 | final IMarkerFactory markerFactory = new BasicMarkerFactory(); 48 | 49 | private StaticMarkerBinder() { 50 | } 51 | 52 | /** 53 | * Currently this method always returns an instance of 54 | * {@link BasicMarkerFactory}. 55 | */ 56 | public IMarkerFactory getMarkerFactory() { 57 | return markerFactory; 58 | } 59 | 60 | /** 61 | * Currently, this method returns the class name of 62 | * {@link BasicMarkerFactory}. 63 | */ 64 | public String getMarkerFactoryClassStr() { 65 | return BasicMarkerFactory.class.getName(); 66 | } 67 | 68 | 69 | } -------------------------------------------------------------------------------- /src/test/java/test/MessageFormatTest.java: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | import org.junit.Test; 4 | import org.slf4j.helpers.FormattingTuple; 5 | import org.slf4j.helpers.MessageFormatter; 6 | 7 | public class MessageFormatTest { 8 | 9 | 10 | @Test 11 | public void messageFormatTest() { 12 | 13 | 14 | } 15 | } 16 | --------------------------------------------------------------------------------