Browse Source
Update `EclipseConventions` to generate a prefs file to force the project to use UTF-8 encoding. Closes gh-48974pull/49013/head
3 changed files with 135 additions and 6 deletions
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
/* |
||||
* Copyright 2025 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.boot.build; |
||||
|
||||
import java.util.Properties; |
||||
|
||||
import org.gradle.api.Task; |
||||
import org.gradle.api.internal.PropertiesTransformer; |
||||
import org.gradle.plugins.ide.api.PropertiesGeneratorTask; |
||||
|
||||
import org.springframework.boot.build.EclipseSynchronizeResourceSettings.Configuration; |
||||
|
||||
/** |
||||
* {@link Task} to synchronize Eclipse resource settings. |
||||
* |
||||
* @author Phillip Webb |
||||
*/ |
||||
public abstract class EclipseSynchronizeResourceSettings extends PropertiesGeneratorTask<Configuration> { |
||||
|
||||
@Override |
||||
protected Configuration create() { |
||||
return new Configuration(getTransformer()); |
||||
} |
||||
|
||||
@Override |
||||
protected void configure(Configuration configuration) { |
||||
} |
||||
|
||||
public static class Configuration extends EmptyPropertiesPersistableConfigurationObject { |
||||
|
||||
Configuration(PropertiesTransformer transformer) { |
||||
super(transformer); |
||||
} |
||||
|
||||
@Override |
||||
protected void store(Properties properties) { |
||||
properties.put("encoding/<project>", "UTF-8"); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
/* |
||||
* Copyright 2025 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.boot.build; |
||||
|
||||
import java.io.ByteArrayInputStream; |
||||
import java.util.Properties; |
||||
|
||||
import org.gradle.api.internal.PropertiesTransformer; |
||||
import org.gradle.internal.UncheckedException; |
||||
import org.gradle.plugins.ide.internal.generator.PropertiesPersistableConfigurationObject; |
||||
|
||||
/** |
||||
* Base class for {@link PropertiesPersistableConfigurationObject} instances start empty |
||||
* and have no default resource. |
||||
* |
||||
* @author Phillip Webb |
||||
*/ |
||||
abstract class EmptyPropertiesPersistableConfigurationObject extends PropertiesPersistableConfigurationObject { |
||||
|
||||
EmptyPropertiesPersistableConfigurationObject(PropertiesTransformer transformer) { |
||||
super(transformer); |
||||
} |
||||
|
||||
@Override |
||||
protected String getDefaultResourceName() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void loadDefaults() { |
||||
try { |
||||
load(new ByteArrayInputStream(new byte[0])); |
||||
} |
||||
catch (Exception ex) { |
||||
throw UncheckedException.throwAsUncheckedException(ex); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected void load(Properties properties) { |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue