Skip to content

Instantly share code, notes, and snippets.

View gastaldi's full-sized avatar
🏠
Working from home

George Gastaldi gastaldi

🏠
Working from home
View GitHub Profile
@gastaldi
gastaldi / gist:2403701
Created April 17, 2012 05:27
Converting to Unicode
/*
* Converts unicodes to encoded \uxxxx and escapes special characters
* with a preceding slash
*/
private static String saveConvert(String theString, boolean escapeSpace, boolean escapeUnicode) {
int len = theString.length();
int bufLen = len * 2;
if (bufLen < 0) {
bufLen = Integer.MAX_VALUE;
}
/*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
package com.george.hint.impl;
import org.jboss.forge.project.Facet;
import org.jboss.forge.project.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A Holder object to ease working with Drools
*
@Override
public DirectoryResource getSourceFolder()
{
MavenCoreFacet mavenFacet = project.getFacet(MavenCoreFacet.class);
Build build = mavenFacet.getPOM().getBuild();
String srcFolderName;
if (build != null && build.getSourceDirectory() != null) {
srcFolderName = build.getSourceDirectory();
} else {
srcFolderName = "src" + File.separator + "main" + File.separator + "java";
@gastaldi
gastaldi / gist:3340292
Created August 13, 2012 12:42
Forge UrlResource
package org.jboss.forge.resources;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import org.jboss.forge.project.services.ResourceFactory;
public class BeanManagerExtension implements Extension {
private static volatile BeanManager beanManager;
public void init(@Observes AfterDeploymentValidation evt, BeanManager bm) {
BeanManagerExtension.beanManager = bm;
}
public void destroy(@Observes Shutdown forgeShutdown) {
BeanManagerExtension.beanManager = null;
}
@gastaldi
gastaldi / DeprecatedPlugin.java
Created August 25, 2012 22:55
Forge Deprecated plugin
package com.forge.plug;
import java.io.IOException;
import javax.inject.Inject;
import org.jboss.forge.parser.java.JavaSource;
import org.jboss.forge.parser.java.Method;
import org.jboss.forge.project.Project;
import org.jboss.forge.project.facets.JavaSourceFacet;
@gastaldi
gastaldi / gist:3502224
Created August 28, 2012 18:51
GoogleAnalytics
/*
* Copyright 2012 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.jboss.forge.shell.analytics;
import java.text.DateFormat;
/**
* Updates the forge version
*
* @param specificVersion if you need a specific version
*/
@Command(value = "update", help = "Update this forge installation")
public void update() throws IOException
{
Dependency forgeDistribution = getLatestAvailableDistribution();
if (forgeDistribution == null)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.george.app</groupId>
<artifactId>teste-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>far</packaging>
<build>
<plugins>